#!/bin/pwsh
$env:NVS_HOME="$env:ProgramData\nvs";
git clone "https://github.com/jasongin/nvs.git" "$env:NVS_HOME";
& "$env:NVS_HOME\nvs.cmd" install;

$acl = Get-Acl "$env:NVS_HOME";

$acl.AddAccessRule(
    [System.Security.AccessControl.FileSystemAccessRule]::new(
        [System.Security.Principal.SecurityIdentifier]::new([System.Security.Principal.WellKnownSidType]::BuiltinUsersSid, $null),
        [System.Security.AccessControl.RegistryRights]::FullControl,
        [System.Security.AccessControl.InheritanceFlags]::ObjectInherit -bor [System.Security.AccessControl.InheritanceFlags]::ContainerInherit,
        [System.Security.AccessControl.PropagationFlags]::InheritOnly,
        [System.Security.AccessControl.AccessControlType]::Allow));

Set-Acl "$env:NVS_HOME" $acl;

refreshenv;
nvs add latest;
nvs link latest;