X
XYZ
Guest
Couple of Powershell questions.
1. Is the right/best way to set powershell execution policy by integrating registry file? If not, what is best way. For example, after integrating following .reg file into image, I was still asked to confirm execution policy when I copied a powershell script into virtual machine Win desktop, right-clicked and run with powershell. Why doesn't integrated .reg stop me from being asked to set execution policy ?
2. I am trying to run a Post-Setup .ps1 powershell script to change the height of the taskbar to 3 (code is below, but it's only supposed to take effect after restarting explorer.exe, logging off/on, or rebooting), so I add the .ps1 script file to Post-Setup User-Execution queue. After NTLite processing, the the .ps1 script file is correctly placed in sources\$OEM$\$$\Setup\FilesU, and also appears in the ISO. When I install the ISO into VirtualBox, taskbar stays at height 1, and relevant registry key value byte is also at 1. Restarting explorer.exe, logging off/on/rebooting obviously doesn't work because registry value byte hasn't been changed to 3.
However, If I then manually right click-the .ps1 file > Run with powershell in the same VM Windows, I am asked to Set-Execution Policy, and after saying Y, and restarting explorer.exe the taskbar is height 3, as expected.
Not sure if it is being executed too early by NTLite, and then overwritten some-how by Windows, even though I expected NTLite to make it run when user logs in.
Any ideas ?
The code for the script is below:
1. Is the right/best way to set powershell execution policy by integrating registry file? If not, what is best way. For example, after integrating following .reg file into image, I was still asked to confirm execution policy when I copied a powershell script into virtual machine Win desktop, right-clicked and run with powershell. Why doesn't integrated .reg stop me from being asked to set execution policy ?
Code:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell]
"Path"="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
"ExecutionPolicy"="RemoteSigned"
2. I am trying to run a Post-Setup .ps1 powershell script to change the height of the taskbar to 3 (code is below, but it's only supposed to take effect after restarting explorer.exe, logging off/on, or rebooting), so I add the .ps1 script file to Post-Setup User-Execution queue. After NTLite processing, the the .ps1 script file is correctly placed in sources\$OEM$\$$\Setup\FilesU, and also appears in the ISO. When I install the ISO into VirtualBox, taskbar stays at height 1, and relevant registry key value byte is also at 1. Restarting explorer.exe, logging off/on/rebooting obviously doesn't work because registry value byte hasn't been changed to 3.
However, If I then manually right click-the .ps1 file > Run with powershell in the same VM Windows, I am asked to Set-Execution Policy, and after saying Y, and restarting explorer.exe the taskbar is height 3, as expected.
Not sure if it is being executed too early by NTLite, and then overwritten some-how by Windows, even though I expected NTLite to make it run when user logs in.
Any ideas ?
The code for the script is below:
C#:
$path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3"
$objName = "Settings"
$getObj = Get-ItemProperty -path $path -name $objName
$getObj.Settings[44] = 0x03
$objValue = $getObj.Settings
Set-ItemProperty -path $path -name $objName -Value $objValue