# Defined Parameters਀嬀䌀洀搀氀攀琀䈀椀渀搀椀渀最⠀⤀崀 param(਀嬀猀眀椀琀挀栀崀␀吀攀猀琀Ⰰ [Parameter(Mandatory=$True,Position=0)]਀嬀猀琀爀椀渀最崀␀唀䌀匀䴀Ⰰ [Parameter(Mandatory=$True,Position=1)]਀嬀猀琀爀椀渀最崀␀䈀氀愀搀攀䐀攀琀愀椀氀猀䌀匀嘀倀愀琀栀Ⰰ [Parameter(Mandatory=$True,Position=2)]਀嬀猀琀爀椀渀最崀␀䈀氀愀搀攀Ⰰ [Parameter(Mandatory=$True,Position=3)]਀嬀猀琀爀椀渀最崀␀䌀栀愀猀猀椀猀 )਀ # Check if CSV is exist਀䤀昀 ⠀⠀吀攀猀琀ⴀ倀愀琀栀 ␀䈀氀愀搀攀䐀攀琀愀椀氀猀䌀匀嘀倀愀琀栀⤀ ⴀ攀焀 ∀吀爀甀攀∀⤀ 笀 $Blades = Import-Csv $BladeDetailsCSVPath -ErrorAction SilentlyContinue -WarningAction SilentlyContinue਀⌀ 䤀昀 ⴀ琀攀猀琀 漀瀀琀椀漀渀 洀攀渀琀椀漀渀 琀栀攀渀 攀砀攀挀甀琀攀 昀漀氀氀漀眀椀渀最 猀挀爀椀瀀琀ऀ if ($Test.IsPresent) { ਀ऀऀ䤀昀 ⠀䜀攀琀ⴀ䴀漀搀甀氀攀 ⴀ一愀洀攀 䌀椀猀挀漀唀挀猀倀匀⤀ 笀 Write-Host "UCS Module is Installed" ਀ऀऀ紀 Else {਀ऀऀऀ圀爀椀琀攀ⴀ䠀漀猀琀 ∀唀䌀匀 䴀漀搀甀氀攀 一漀琀 䤀渀猀琀愀氀氀攀搀⸀ 倀氀攀愀猀攀 椀渀猀琀愀氀氀 唀䌀匀 䴀漀搀甀氀攀 琀漀 攀砀攀挀甀琀攀 唀䌀匀 匀挀爀椀瀀琀猀∀ }਀ऀऀ圀爀椀琀攀ⴀ䠀漀猀琀 ∀唀䌀匀䴀㨀␀唀䌀匀䴀∀ ⴀ䘀漀爀攀最爀漀甀渀搀䌀漀氀漀爀 䜀爀攀攀渀 Write-Host "You have mention testing option hence it is just a testing. It will not be implemented" -ForegroundColor DarkRed -BackgroundColor White਀ऀऀ␀䈀氀愀搀攀猀 簀 ─ 笀眀爀椀琀攀ⴀ䠀漀猀琀 ∀匀攀琀ⴀ唀挀猀䈀氀愀搀攀 ⴀ䈀氀愀搀攀 ␀⠀␀开⸀䌀栀愀猀猀椀猀䤀䐀⤀∀⼀∀␀⠀␀开⸀䈀氀愀搀攀䤀䐀⤀ ⴀ唀猀爀䰀戀氀 ␀⠀␀开⸀唀猀攀爀䰀愀戀攀氀⤀ ⴀ䔀爀爀漀爀䄀挀琀椀漀渀 匀椀氀攀渀琀氀礀䌀漀渀琀椀渀甀攀 ⴀ圀愀爀渀椀渀最䄀挀琀椀漀渀 匀椀氀攀渀琀氀礀䌀漀渀琀椀渀甀攀 ⴀ䔀爀爀漀爀嘀愀爀椀愀戀氀攀 攀爀∀紀 }਀ऀ攀氀猀攀椀昀 ⠀␀戀氀愀搀攀⸀䤀猀倀爀攀猀攀渀琀⤀笀 # Check if CiscoUCS module exist on system annd import it if exist਀ऀऀ䤀昀 ⠀䜀攀琀ⴀ䴀漀搀甀氀攀 ⴀ一愀洀攀 䌀椀猀挀漀唀挀猀倀匀⤀ 笀  Write-Host "UCSM:$UCSM"਀ऀऀऀ䤀洀瀀漀爀琀ⴀ䴀漀搀甀氀攀 䌀椀猀挀漀唀挀猀倀匀 ⴀ圀愀爀渀椀渀最䄀挀琀椀漀渀 匀椀氀攀渀琀氀礀䌀漀渀琀椀渀甀攀 ⴀ䔀爀爀漀爀䄀挀琀椀漀渀 匀椀氀攀渀琀氀礀䌀漀渀琀椀渀甀攀 ⴀ䔀爀爀漀爀嘀愀爀椀愀戀氀攀 䔀爀爀 If ($err) {਀ऀऀऀऀ圀爀椀琀攀ⴀ䠀漀猀琀 ∀唀渀愀戀氀攀 琀漀 椀洀瀀漀爀琀 唀䌀匀 洀漀搀甀氀攀∀ ⴀ䘀漀爀攀最爀漀甀渀搀䌀漀氀漀爀 刀攀搀 }਀ऀऀऀ䔀氀猀攀 笀 # Check UCSM is reachable਀ऀऀऀऀ椀昀 ⠀⠀吀攀猀琀ⴀ䌀漀渀渀攀挀琀椀漀渀 ␀唀䌀匀䴀 ⴀ儀甀椀攀琀 ⴀ䌀漀甀渀琀 ㈀⤀ ⴀ攀焀 ∀吀爀甀攀∀⤀笀  $cred = Get-Credential਀ऀऀऀऀऀ␀栀愀渀搀氀攀㄀ 㴀 䌀漀渀渀攀挀琀ⴀ唀挀猀 ␀唀䌀匀䴀 ⴀ䌀爀攀搀攀渀琀椀愀氀 ␀挀爀攀搀 ⴀ䔀爀爀漀爀䄀挀琀椀漀渀 匀椀氀攀渀琀氀礀䌀漀渀琀椀渀甀攀 ⴀ圀愀爀渀椀渀最䄀挀琀椀漀渀 匀椀氀攀渀琀氀礀䌀漀渀琀椀渀甀攀 $handle1 | Out-Null਀ऀऀऀऀऀ䤀昀 ⠀␀䐀攀昀愀甀氀琀唀挀猀⤀ 笀 ⌀ 䌀栀攀挀欀 椀昀 挀漀渀渀攀挀琀攀搀 琀漀 唀䌀匀䴀 Write-Host "Connected to UCSM:"$UCSM -ForegroundColor Green਀⌀ 唀瀀搀愀琀椀渀最 唀猀攀爀 䰀愀戀攀氀 漀渀 戀氀愀搀攀ऀऀऀऀऀऀ Foreach ($bladeID in $blades) { ਀ऀऀऀऀऀऀऀ␀唀䌀匀戀氀愀搀攀 㴀 䜀攀琀ⴀ唀挀猀䈀氀愀搀攀 ⴀ䌀栀愀猀猀椀猀 ␀戀氀愀搀攀䤀䐀⸀䌀栀愀猀猀椀猀䤀䐀 ⴀ匀氀漀琀䤀搀 ␀戀氀愀搀攀䤀䐀⸀䈀氀愀搀攀䤀䐀 ⴀ䔀爀爀漀爀䄀挀琀椀漀渀 匀椀氀攀渀琀氀礀䌀漀渀琀椀渀甀攀 ⴀ圀愀爀渀椀渀最䄀挀琀椀漀渀 匀椀氀攀渀琀氀礀䌀漀渀琀椀渀甀攀 Set-UcsBlade -Blade $UCSblade -UsrLbl $($bladeID.UserLabel) -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -ErrorVariable er -Confirm:$false -Force | Out-Null਀ऀऀऀऀऀऀऀ䤀昀 ⠀␀攀爀⤀笀 Write-Host "Blade"$bladeID.ChassisID"/"$bladeID.BladeID" - Failed" -ForegroundColor Red਀ऀऀऀऀऀऀऀ紀 else{਀ऀऀऀऀऀऀऀऀ圀爀椀琀攀ⴀ䠀漀猀琀 ∀䈀氀愀搀攀∀␀戀氀愀搀攀䤀䐀⸀䌀栀愀猀猀椀猀䤀䐀∀⼀∀␀戀氀愀搀攀䤀䐀⸀䈀氀愀搀攀䤀䐀∀ ⴀ 䌀漀洀瀀氀攀琀攀搀∀ ⴀ䘀漀爀攀最爀漀甀渀搀䌀漀氀漀爀 䜀爀攀攀渀 }਀ऀऀऀऀऀऀ紀 # Disconnect UCS ਀ऀऀऀऀऀऀ䐀椀猀挀漀渀渀攀挀琀ⴀ唀挀猀 }਀ऀऀऀऀऀ攀氀猀攀 笀 Write-Host "Unable to connect UCSM" -ForegroundColor Red਀ऀऀऀऀऀ紀 }਀ऀऀऀऀ攀氀猀攀笀 Write-Host "UCSM not reachable on network"਀ऀऀऀऀ紀 }਀ऀऀ紀 Else {਀ऀऀऀ圀爀椀琀攀ⴀ䠀漀猀琀 ∀䌀椀猀挀漀唀䌀匀 䴀漀搀甀氀攀 一漀琀 䤀渀猀琀愀氀氀攀搀∀ ⴀ䘀漀爀攀最爀漀甀渀搀䌀漀氀漀爀 刀攀搀 }਀ऀ紀 elseif($chassis.IsPresent){਀ऀ }਀紀 else {਀ऀ圀爀椀琀攀ⴀ䠀漀猀琀 ∀䌀匀嘀 渀漀琀 攀砀椀猀琀∀ ⴀ䘀漀爀攀最爀漀甀渀搀䌀漀氀漀爀 刀攀搀 }