Scripteur Posted May 11, 2018 Report post Posted May 11, 2018 Hello, I need your precious help. I tried to deploy W10 OS using captured image and task sequence on computer that has 2 disks. there is W7 OS already installed on disk 1, I have created a package included a powershell script that detect automatically the disk index where the W7 OS already installed and change value of OSDDiskindex variable accordingly so in next step Format and partition TS take this variable into consideration, but no success!! My aim is to deploy W10 OS on this same disk but I am not able to use OSDDiskindex effeciently in my TS. Could you a please help me? Your help will be so much apprecied! Quote Share this post Link to post Share on other sites More sharing options...
anyweb Posted May 11, 2018 Report post Posted May 11, 2018 the first thing i'd say is why 2 disks ? and, when you say it's not working efficiently, can you explain what is not working exactly ? what errors are you seeing, and can you zip up and attach the smsts.log ? Quote Share this post Link to post Share on other sites More sharing options...
Scripteur Posted May 11, 2018 Report post Posted May 11, 2018 Thanks for your quick reply. In our company, there is some developpers that need two disk on their computers. here is the command line that I execute before Format and partition step. powershell –executionpolicy bypass "@{ Get-WmiObject Win32_DiskDrive | % { $disk = $_ $partitions = "ASSOCIATORS OF " + "{Win32_DiskDrive.DeviceID='$($disk.DeviceID)'} " + "WHERE AssocClass = Win32_DiskDriveToDiskPartition" Get-WmiObject -Query $partitions | % { $partition = $_ $drives = "ASSOCIATORS OF " + "{Win32_DiskPartition.DeviceID='$($partition.DeviceID)'} " + "WHERE AssocClass = Win32_LogicalDiskToPartition" Get-WmiObject -Query $drives |Where-Object {$_.DeviceID -eq "C:"} | % { $MonDisk = New-Object -Type PSCustomObject @{ Disk = $disk.index } $MonDisk.Disk } } } (New-Object -COMObject Microsoft.SMS.TSEnvironment).Value('OSDDiskIndex') = $MonDisk.Disk }" and error is : Le moteur d'exécution des séquences de tâches a terminé l'action (Set Disk number) dans le groupe (Installer le système d'exploitation) avec code de sortie 0 Sortie de l'action : ... = $disk.index } $MonDisk.Disk } } } (New-Object -COMObject Microsoft.SMS.TSEnvironment).Value('OSDDiskIndex') = $MonDisk.Disk }" returned 0 Au caractŠre Ligne:1 : 7 + @{ Get-WmiObject Win32_DiskDrive | % { $disk = $_ $partitions = ASSOCIATORS ... + ~ Op‚rateur ®ÿ=ÿ¯ manquant aprŠs la cl‚ dans le litt‚ral de hachage. Au caractŠre Ligne:1 : 7 + @{ Get-WmiObject Win32_DiskDrive | % { $disk = $_ $partitions = ASSOCIATORS ... + ~ Le litt‚ral de hest incomplet. Au caractŠre Ligne:1 : 648 + ... k } } } (New-Object -COMObject Microsoft.SMS.TSEnvironment).Value('OSDDis ... + ~ Jeton inattendu ®ÿ(ÿ¯ dans l'expression ou l'instruction. Au caractŠre Ligne:1 : 738 + ...$MonDisk.Disk } + ~ Jeton inattendu ®ÿ}ÿ¯ dans l'expression ou l'instruction. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx ception + FullyQualifiedErrorId : MissingEqualsInHashLiteral. thank you for your help! Quote Share this post Link to post Share on other sites More sharing options...
anyweb Posted May 11, 2018 Report post Posted May 11, 2018 so you are running an English PowerShell script on a French OS ? that might be part of your problem, "ASSOCIATORS OF" might be something else in French..just a thought have you actually tried running this script on that computer without running it in the task sequence, (New-Object -COMObject Microsoft.SMS.TSEnvironment).Value('OSDDiskIndex') = $MonDisk.Disk }" will fail as no task sequence is running but if your script works (and i'm not sure it is working), then you should get some valid output Quote Share this post Link to post Share on other sites More sharing options...
Scripteur Posted May 14, 2018 Report post Posted May 14, 2018 Thanks for your reply! no problem with the script, it is given me the right Output, my problem is how to set this output ( OSDDiskIndex variable) in my Task Sequence. Thanks Quote Share this post Link to post Share on other sites More sharing options...
anyweb Posted May 14, 2018 Report post Posted May 14, 2018 but you pasted above that it's producing an error on line 7 ? Quote Share this post Link to post Share on other sites More sharing options...
Scripteur Posted May 15, 2018 Report post Posted May 15, 2018 yes when I excute it on Task sequence, it givens error! But how can use a custom variable in task sequence? thanks Quote Share this post Link to post Share on other sites More sharing options...
anyweb Posted May 15, 2018 Report post Posted May 15, 2018 I can't see that you can use it if it produces errors when run during the task sequence, how can it set the variable if it doesn't work, do you see my point ? if I was using a script to set a variable i'd add a logging function to see where it's failing, below is an example function Function LogWrite { Param ([string]$logstring) $a = Get-Date $logstring = $a,$logstring Try { Add-content $Logfile -value $logstring -ErrorAction silentlycontinue } Catch { $logstring="Invalid data encountered" Add-content $Logfile -value $logstring } write-host $logstring } # script starts here $Logfile = "C:\Windows\temp\logfile.log" so for each action in your script use LogWrite "about to do... whatever" so you can see where it fails... once you fix the script, then you can use the variable in the task sequence Quote Share this post Link to post Share on other sites More sharing options...
Scripteur Posted May 15, 2018 Report post Posted May 15, 2018 I can confirm you that this script is working when execute in localy in my machine, you can test it in your machine to be sure. thanks Get-WmiObject Win32_DiskDrive | % { $disk = $_ $partitions = "ASSOCIATORS OF " + "{Win32_DiskDrive.DeviceID='$($disk.DeviceID)'} " + "WHERE AssocClass = Win32_DiskDriveToDiskPartition" Get-WmiObject -Query $partitions | % { $partition = $_ $drives = "ASSOCIATORS OF " + "{Win32_DiskPartition.DeviceID='$($partition.DeviceID)'} " + "WHERE AssocClass = Win32_LogicalDiskToPartition" Get-WmiObject -Query $drives |Where-Object {$_.DeviceID -eq "C:"} | % { $MonDisk = New-Object -Type PSCustomObject @{ Disk = $disk.index } $MonDisk.Disk } } } Quote Share this post Link to post Share on other sites More sharing options...
anyweb Posted May 15, 2018 Report post Posted May 15, 2018 yup works ok for me, so before we go any further, can you explain where you got the error's you posted, and what happens when you run the code pasted directly above this reply on that machine (and not in the task sequence), does it produce an error, or not, or, do you only see an error when you run the script via the task sequence Quote Share this post Link to post Share on other sites More sharing options...