通过GPO应用时,Powershell脚本未运行。 [英] Powershell script not running when applied through GPO.

查看:419
本文介绍了通过GPO应用时,Powershell脚本未运行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆