如何在WDS部署的专门化传递期间运行PowerShell脚本?
发布时间:2020-12-13 22:59:09 所属栏目:Windows 来源:网络整理
导读:我正在使用安装介质上的默认boot.wim文件为 Windows Server 2012无人参与部署设置 Windows Deployment Services(WDS).我有一个PowerShell脚本,可以为我们的网站执行自动定制.我希望这个脚本在specialize pass期间运行,所以我不必乱用自动登录,并且能够在配置
我正在使用安装介质上的默认boot.wim文件为
Windows Server 2012无人参与部署设置
Windows Deployment Services(WDS).我有一个PowerShell脚本,可以为我们的网站执行自动定制.我希望这个脚本在specialize pass期间运行,所以我不必乱用自动登录,并且能够在配置期间保存自己重启.该脚本似乎没有运行,日志只提供无用的错误代码.
这是我的无人参与文件的相关部分: <settings pass="specialize"> <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <RunSynchronous> <RunSynchronousCommand wcm:action="add"> <Order>1</Order> <Credentials> <Domain>WDSSERVER</Domain> <Password>APASSWORD</Password> <Username>AUSERNAME</Username> </Credentials> <Path>"c:windowssystem32windowspowershellv1.0powershell.exe" -executionpolicy unrestricted -command "<REMOTESERVER>reminstcustomizespecialize.ps1"</Path> </RunSynchronousCommand> </RunSynchronous> </component> </settings> 响应来自kce的请求.这是脚本本身: write-host "Executing customisation script." write-host "enabling powershell script execution" Set-ExecutionPolicy Unrestricted write-host "Bringing non-system disks online..." Get-Disk | Where-Object IsOffline –Eq $True | Set-Disk –IsOffline $False Set-Disk -Number 1 -IsReadOnly $False Set-Disk -Number 2 -IsReadOnly $False write-host "Setting up NTP..." W32tm /register start-service w32time w32tm /config /manualpeerlist:uk.pool.ntp.org restart-service w32time Set-Service W32Time -StartupType Automatic sc triggerinfo w32time start/networkon stop/networkoff sc config W32Time start=auto write-host "Determining system RAM and setting pagefile..." $RAM = Get-WmiObject -Class Win32_OperatingSystem | Select TotalVisibleMemorySize $RAM = ($RAM.TotalVisibleMemorySize / 1kb).tostring("F00") write-host "disable automanage" wmic computersystem set AutomaticManagedPagefile=False Write-Host "removing old pagefile" wmic pagefileset delete write-host "creating new pagefile on E:" wmic pagefileset create name=“e:pagefile.sys” write-host "set size" $PageFile = Get-WmiObject -Class Win32_PageFileSetting $PageFile.InitialSize = $RAM $PageFile.MaximumSize = $RAM [void]$PageFile.Put() write-host "Disabling Windows Firewall..." netsh advfirewall set allprofiles state off write-host "Enabling powershell remoting..." Enable-PSRemoting -Force write-host "Sorting out remote management trusted hosts..." winrm s winrm/config/client '@{TrustedHosts="*"}' write-host "Disabling Windows error reporting..." Disable-WindowsErrorReporting write-host "Installing VMware Tools..." c:vmware-tools.exe /S /v"/qn"
从我正在阅读的内容来看,未抛出的抛出导致退出代码为1.此外,当它应该通过-file开关传递时,你通过-command开关传入脚本路径;请参阅
the reference. -command会将您的字符串视为一个命令,因为它是一个文件路径,它会在PowerShell窗口中抛出我们喜欢的那些相同的红色字母异常之一,瞧!退出代码1,因为异常未被捕获.当然,所有这些都是猜测,除非
"powershell.exe" -executionpolicy bypass -noprofile -file "<REMOTESERVER>reminstcustomizespecialize.ps1" 实际上是有效的,假设它运行的帐户具有文件共享的权限.要避免这些权限问题,您只需将代码粘贴到{}之间的答案文件中,然后使用-command选项, "powershell.exe" -executionpolicy bypass -noprofile -command {...} (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows – 用于“Git Bash Here”的CMD命令
- xaml – 在文本块中裁剪的长文本
- 适用于WIndows 7 x64的Cisco VPN客户端
- WinForm事件中的Object sender和EventArgs e参数
- Windows Azure:使用第三方Web服务
- windows-phone-7 – 适用于Windows Phone 7的中继器或类似设
- Windows server 1709(不含UI)模板部署
- .net – 从TripleDES更改Microsoft配置文件加密方法
- windows-update – 是否有“wusa.exe”的完整返回代码列表?
- Win10 下不能正常使用Multilink解决办法
推荐文章
站长推荐
热点阅读