Sample/OS_Deployment.ps1
<#
OS_Deployment.ps1 - Example scripts to illustrate how to deploy os image to target systems. Lenovo Copyright © Copyright Lenovo 2015. LIMITED AND RESTRICTED RIGHTS NOTICE: If data or software is delivered pursuant a General Services Administration “GSA” contract, use, reproduction, or disclosure is subject to restrictions set forth in Contract No. GS-35F-05925. #> # Define the variable value $LxcaUserName = "USERID" $LxcaPassword = ConvertTo-SecureString "Password" -AsPlainText –Force $LxcaIP = "10.240.197.26" $targetSystem = @{ uuid = "89B8E140DF7C11D49AB09F8B8B8B8B8B" systemType = "RackServer" } $deploySet = @{ macAddress = "40:F2:E9:B8:1B:68" imageProfileId = "win2012|win2012-x86_64-install-Datacenter" targetDevice = "localdisk" # localdisk / usbdisk / sandisk (SAN ID is required) IpAssignment = "dhcpv4" # dhcpv4 / staticv4 } # First connect to LXCA server $Cred = New-Object System.Management.Automation.PSCredential($LxcaUserName, $LxcaPassword) Connect-LXCA $LxcaIP -Credential $Cred -SkipCertificateCheck # Deploy OS image to target system # Set global deploy setting $globalSet = Get-LXCADeployGlobalSetting $globalSet.IpAssignment = $deploySet.IpAssignment Set-LXCADeployGlobalSetting -DeployGlobalSetting $gloalSet # Create a deploy task $deployTask = New-LXCADeployTask -MacAddress $deploySet.macAddress -ServerUuid $targetSystem.uuid -ImageProfileID $deploySet.imageProfileId -TargetDevice $deploySet.targetDevice -Mtu 1500 -PrefixLength 0 # Deploy OS image to target system $ret = Install-LXCAOSImage -DeployTask $deployTask if ($ret -eq $null) { Write-Host "Install-LXCAOSImage is failed with unexcepted error!" -ForegroundColor Red } else { $ret | Format-Table -Property ServerUuid,Percentage,Result,Message -Wrap } # Disconnect from LXCA server Disconnect-LXCA |