I am trying to create unattended.xml file for windows server 2016 unattended installation where in after installing windows it should execute one powershell script located on remote samba share.
I am using following command to run powershell script stored in samba share:
cmd.exe /c "ECHO R | powershell.exe -ExecutionPolicy Unrestricted -File \\192.168.137.131\install\ConfigureRemotingForAnsible.ps1"
The Unattended installation process works well but ConfigureRemotingForAnsible.ps1 script execution fails with error:
The argument '\\192.168.137.131\install\ConfigureRemotingForAnsible.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.
The same command executes successfully when I run it manually.
Relevant portion of unattended.xml file:
<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">
<Credentials>
<Username>Administrator</Username>
<Password>Devops@123</Password>
</Credentials>
<Path>cmd.exe /c "ECHO R | powershell.exe -ExecutionPolicy Unrestricted -File \\192.168.137.131\install\ConfigureRemotingForAnsible.ps1 > c:\pss.txt"</Path>
<Order>1</Order>
<Description>Execute ansible script</Description>
</RunSynchronousCommand>
</RunSynchronous>
</component>
</settings>
Can somebody tell me what should I add in my unattended.xml to make it working?
Thanks in advance.
Из документации кажется, что к элементу Path осуществляется доступ с использованием предоставленных учетных данных, но не запускать как . В общих чертах он говорит, что RunSynchronousCommand
во время Specialize
выполняется в системном контексте, тогда как AuditUser
будет работать от имени пользователя.
Некоторые параметры:
Specialize
подключите диск с явными учетными данными к удаленному общему ресурсу, используя net use
или New-PSDrive
AuditUser
. В комментариях OP упоминалось, что у этого были другие проблемы. Я имею в виду документы на https: // docs .microsoft.com / en-us / windows-hardware / customize / desktop / unattend / microsoft-windows-deployment-runynchronous-runynchronouscommand-credentials и https://technet.microsoft.com/en- us / library / cc722343 (v = ws.10) .aspx