Jump to content




Scripteur

Problem deploy OS on computer that has 2 or more disks



Recommended Posts

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!

 

Share this post


Link to post
Share on other sites


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 ?

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

but you pasted above that it's producing an error on line 7 ?

Share this post


Link to post
Share on other sites

yes when I excute it on Task sequence, it givens error!

But how can use a custom variable in task sequence? thanks

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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
    }
  }
}

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Exact I see the error when I try to apply the output to OSDDiskIndex variable in the task sequence using Run Command Line :

(New-Object -COMObject Microsoft.SMS.TSEnvironment).Value('OSDDiskIndex') = $MonDisk.Disk }"

thanks

Share this post


Link to post
Share on other sites
(New-Object -COMObject Microsoft.SMS.TSEnvironment).Value('OSDDiskIndex') = $MonDisk.Disk }" returned 0

 

doesn't look like it's an error, have you tried to dump the variables created to verify it it set's the variable at all ? i'd suggest you pause the task sequence before and after the step to verify

 

 

Share this post


Link to post
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


×