通过GPO应用时,Powershell脚本未运行。 [英] Powershell script not running when applied through GPO.
问题描述
我正在通过GPO将脚本应用到工作站。问题是当我通过GPO部署它时脚本没有应用,但我可以在登录工作站时部署它。
这是脚本:
Set-ExecutionPolicy Unrestricted
#define URL的商店编号
$ wks = $ env:computername
$ number = $ wks.substring(3,3)
#创建快捷方式
$ Shell = New-Object -ComObject(" WScript.Shell")
$ ShortCut = $ Shell.CreateShortcut($ env:USERPROFILE +" \Desktop\Chrome.lnk")
$ ShortCut.TargetPath =" C:\Program Files(x86)\\ \\Google\Chrome\Application\chrome.exe"
$ ShortCut.Arguments =" -kisok https://dom-prod/wsc/login.do?StoreId = SCXX $ number"
$ ShortCut.WorkingDirectory =" C:\Program Files(x86)\Google \ Chrome \ Application \" ;;
$ ShortCut.Save()
任何想法?
您无法在登录脚本中更改执行策略。 使用PowerShell GPO更改它。
PowerShell脚本不受大多数执行政策限制的约束。
您需要使用GP首选项策略来创建快捷方式。  ;请勿在登录脚本中执行此操作。
在GP论坛中发布以获取GPO帮助。
Hi, I am applying a script to a workstation through GPO. The thing is that the script is not applying when I am deploying it through GPO, but I can deploy it when I am log in to workstation.
Here is the script:
Set-ExecutionPolicy Unrestricted # define store number for URL $wks = $env:computername $number = $wks.substring(3,3) # Create shortcut $Shell = New-Object -ComObject ("WScript.Shell") $ShortCut = $Shell.CreateShortcut($env:USERPROFILE + "\Desktop\Chrome.lnk") $ShortCut.TargetPath="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" $ShortCut.Arguments= "-kisok https://dom-prod/wsc/login.do?StoreId=SCXX$number" $ShortCut.WorkingDirectory = "C:\Program Files (x86)\Google\Chrome\Application\"; $ShortCut.Save()
Any ideas?
You cannot change the execution policy in a login script. Change it with the PowerShell GPO.
PowerShell scripts are exempt from most execution policy restrictions.
You need to use a GP Preferences Policy to create a shortcut. DO not do it in a login script.
Post in GP forum for help doing this with a GPO.
这篇关于通过GPO应用时,Powershell脚本未运行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!