简体   繁体   中英

Powershell Startup Script GPO Not Applying

Pretty basic script used to create a web shortcut on the PC's desktop, but it's not applying for some reason. I have it set in the gpo under

Computer Configuration->Policies-> Windows Settings-> Scripts-> Startup->

Added the powershell script-> And set it to run the powershell script first.

I also know the script works because I have tried running it manually on the machine without admin privileges or anything and it appears just fine.

$DesktopPath = [Environment]::GetFolderPath("Desktop") + "\Prophet21.url"
 
$WshShell = New-Object -comObject WScript.Shell 
$Shortcut = $WshShell.CreateShortcut($DesktopPath) 
$Shortcut.TargetPath = "https://p21.gallagherseals.com/prophet21/#/login" $Shortcut.Save()

You're running the code in the wrong context, to run as a user and affect a user, you need to deploy this as a User Configuration .

When you run a Startup Script for a Computer, this happens when the PC is Domain Joined and will process shortly after displaying the initial login screen silently in the background.

But because there is no user logged in yet, some items aren't available.

To fix this, just deploy it as a User Configuration , the full path to the setting would be:

User Configuration -> Policies -> Windows Settings -> Scripts (Logon / Logoff);

The better approach

However, GPO also natively supports creating Desktop Icons with a nice and easy to use wizard. Just follow this short guide by Praj Dasai. I used to manage GPO and I would always prefer a native solution to running a script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM