Jump to content

powershell scripts in RunSynchronousCommand does not works


Recommended Posts

I'm tryng to execute two script as synchronous command in my answer file, but they does not runs, they are the order 2 and order 3, the order 1 command runs normally. If I launch those scripts locally, they works.

<?xml version="1.0" encoding="UTF-8"?>

-<unattend xmlns="urn:schemas-microsoft-com:unattend">


-<settings pass="windowsPE">


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-International-Core-WinPE">


-<SetupUILanguage>

<UILanguage>it-IT</UILanguage>

</SetupUILanguage>

<InputLocale>it-IT</InputLocale>

<SystemLocale>it-IT</SystemLocale>

<UILanguage>it-IT</UILanguage>

<UILanguageFallback/>

<UserLocale>it-IT</UserLocale>

</component>


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-Setup">


-<DiskConfiguration>


-<Disk wcm:action="add">


-<CreatePartitions>


-<CreatePartition wcm:action="add">

<Order>2</Order>

<Size>100</Size>

<Type>EFI</Type>

</CreatePartition>


-<CreatePartition wcm:action="add">

<Order>1</Order>

<Size>500</Size>

<Type>Primary</Type>

</CreatePartition>


-<CreatePartition wcm:action="add">

<Order>3</Order>

<Size>16</Size>

<Type>MSR</Type>

</CreatePartition>


-<CreatePartition wcm:action="add">

<Order>4</Order>

<Extend>true</Extend>

<Type>Primary</Type>

</CreatePartition>

</CreatePartitions>


-<ModifyPartitions>


-<ModifyPartition wcm:action="add">

<Order>1</Order>

<Label>WinRE</Label>

<Format>NTFS</Format>

<TypeID>DE94BBA4-06D1-4D40-A16A-BFD50179D6AC</TypeID>

<PartitionID>1</PartitionID>

</ModifyPartition>


-<ModifyPartition wcm:action="add">

<PartitionID>2</PartitionID>

<Order>2</Order>

<Format>FAT32</Format>

<Label>System</Label>

</ModifyPartition>


-<ModifyPartition wcm:action="add">

<Order>3</Order>

<PartitionID>3</PartitionID>

</ModifyPartition>


-<ModifyPartition wcm:action="add">

<Format>NTFS</Format>

<Label>Windows</Label>

<Letter>C</Letter>

<Order>4</Order>

<PartitionID>4</PartitionID>

</ModifyPartition>

</ModifyPartitions>

<WillWipeDisk>true</WillWipeDisk>

<DiskID>0</DiskID>

</Disk>

<WillShowUI>OnError</WillShowUI>

</DiskConfiguration>


-<ImageInstall>


-<OSImage>


-<InstallTo>

<DiskID>0</DiskID>

<PartitionID>4</PartitionID>

</InstallTo>

</OSImage>

</ImageInstall>


-<UserData>


-<ProductKey>

<Key>mykey</Key>

<WillShowUI>Never</WillShowUI>

</ProductKey>

<AcceptEula>true</AcceptEula>

<Organization>PTC</Organization>

<FullName>PTC</FullName>

</UserData>

</component>

</settings>


-<settings pass="specialize">


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-Deployment">


-<RunSynchronous>


-<RunSynchronousCommand wcm:action="add">

<Path>cmd /c net user Administrator /active:yes</Path>

<Order>1</Order>

</RunSynchronousCommand>


-<RunSynchronousCommand wcm:action="add">


-<Credentials>

<Domain>mydomain</Domain>

<Password>mypwd</Password>

<Username>myuser</Username>

</Credentials>

<Path>powershell.exe –ExecutionPolicy Bypass -File "\\share\script.ps1"</Path>

<Order>2</Order>

</RunSynchronousCommand>


-<RunSynchronousCommand wcm:action="add">


-<Credentials>

<Domain>mydomain</Domain>

<Password>mypwd</Password>

<Username>myuser</Username>

</Credentials>

<Path>powershell.exe –ExecutionPolicy Bypass -File "\\share\script2.ps1"</Path>

<Order>3</Order>

</RunSynchronousCommand>

</RunSynchronous>

</component>

</settings>


-<settings pass="oobeSystem">


-<component language="neutral" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" name="Microsoft-Windows-Shell-Setup">


-<OOBE>

<HideEULAPage>true</HideEULAPage>

<HideLocalAccountScreen>true</HideLocalAccountScreen>

<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>

<HideOnlineAccountScreens>true</HideOnlineAccountScreens>

<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>

<SkipMachineOOBE>true</SkipMachineOOBE>

<SkipUserOOBE>true</SkipUserOOBE>

<NetworkLocation>Work</NetworkLocation>

<ProtectYourPC>1</ProtectYourPC>

</OOBE>


-<UserAccounts>


-<AdministratorPassword>

<Value>pwd</Value>

<PlainText>false</PlainText>

</AdministratorPassword>


-<LocalAccounts>


-<LocalAccount wcm:action="add">


-<Password>

<Value>pwd</Value>

<PlainText>false</PlainText>

</Password>

<DisplayName>Administrator</DisplayName>

<Group>Administrators</Group>

<Name>Administrator</Name>

</LocalAccount>

</LocalAccounts>

</UserAccounts>

</component>

</settings>

<cpi:offlineImage xmlns:cpi="urn:schemas-microsoft-com:cpi" cpi:source="wim:c:/virtuallab/22h2/sources/install.wim#Windows 10 Enterprise"/>

</unattend>

 

 

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...