leo815
Member
- Messages
- 20
- Solutions
- 2
- Points
- 3
Hi team,
I am currently working on a software prerequisites deployment and I have a following script that doesn't create the user environment variable but creates the C:\Scratch folder. I have even tried replacing the first line in the script with setx VALUE KEY but still doesn't work. I can get setx and [System.Environment] power shell command to work directly on the PC but need it to deploy via script as I want to create this environment variable and create c:\scratch folder in one hit.
Any assistance would be appreciated. Thanks.
[System.Environment]::SetEnvironmentVariable('VALUE,'KEY',[System.EnvironmentVariableTarget]::User)
$f1 = "C:\SCRATCH"
New-Item $f1 -Type Directory
$rule=new-object System.Security.AccessControl.FileSystemAccessRule ("BUILTIN\Users","FullControl","ContainerInherit,ObjectInherit","None","Allow")
$FolderACL = Get-ACL -Path $f1
$FolderACL.SetAccessRule($rule)
Set-ACL -Path $f1 -AclObject $FolderACL
I am currently working on a software prerequisites deployment and I have a following script that doesn't create the user environment variable but creates the C:\Scratch folder. I have even tried replacing the first line in the script with setx VALUE KEY but still doesn't work. I can get setx and [System.Environment] power shell command to work directly on the PC but need it to deploy via script as I want to create this environment variable and create c:\scratch folder in one hit.
Any assistance would be appreciated. Thanks.
[System.Environment]::SetEnvironmentVariable('VALUE,'KEY',[System.EnvironmentVariableTarget]::User)
$f1 = "C:\SCRATCH"
New-Item $f1 -Type Directory
$rule=new-object System.Security.AccessControl.FileSystemAccessRule ("BUILTIN\Users","FullControl","ContainerInherit,ObjectInherit","None","Allow")
$FolderACL = Get-ACL -Path $f1
$FolderACL.SetAccessRule($rule)
Set-ACL -Path $f1 -AclObject $FolderACL