1+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute (' PSAvoidUsingWriteHost' , ' ' , Justification= ' This script intentinally uses Write-Host to display messages to the user.' )]
12# ### Getting param ####
23param (
34[Parameter (Mandatory = $true , HelpMessage = " Enter FSxN filesystem management IP" )]
45[string ]$ip ,
56[Parameter (Mandatory = $true , HelpMessage = " Enter FSxN username" )]
67[string ]$user ,
78[Parameter (Mandatory = $true , HelpMessage = " Enter FSx filesystem password" )]
8- [string ]$password ,
9+ [SecureString ]$password ,
910[Parameter (Mandatory = $true , HelpMessage = " Enter volume size (in GB)" )]
1011[string ]$volSize ,
1112[Parameter (Mandatory = $true , HelpMessage = " Enter drive letter" )]
1516[string ]$format_disk )
1617
1718Write-Host " Getting disks numbers before startig..." - ForegroundColor yellow
18- $totaldisks = (get-disk | Sort-Object - Property number | Select - Last 1 - ExpandProperty number)
19+ $totaldisks = (get-disk | Sort-Object - Property number | Select-Object - Last 1 - ExpandProperty number)
1920Write-Host " Getting local disks before startig..." - ForegroundColor yellow
2021Write-Host " There are $totaldisks disks" - ForegroundColor yellow
2122
@@ -25,7 +26,7 @@ $lun_name = "drive_" + $vol_number
2526$igroup_name = " winhost_ig_" + $vol_number
2627
2728# ### check if letter drive already in used and in the correct format ####
28- if ($drive_letter.Length > 1 )
29+ if ($drive_letter.Length -gt 1 )
2930{
3031 Write-Host " Drive letter not in the correct format" - ForegroundColor Red
3132 break
@@ -65,7 +66,7 @@ Write-Host "Connectiong to FSx filesystem" -ForegroundColor Yellow
6566$PWord = ConvertTo-SecureString - String $password - AsPlainText - Force
6667$credntials = New-Object - TypeName System.Management.Automation.PSCredential - ArgumentList $user , $PWord
6768try {
68- $controller = Connect-NcController $ip - Credential $credntials - ErrorAction Stop
69+ Connect-NcController $ip - Credential $credntials - ErrorAction Stop
6970}
7071catch {
7172 Write-Host " Failed connect to FSx filesystem, due to: $_ " - ForegroundColor Red
@@ -149,14 +150,14 @@ Write-host 'Online, Initialize and format disks' -ForegroundColor Yellow
149150Start-Sleep - Seconds 10
150151$maxRetries = 5
151152$counter = 0
152- $diskNum = (get-disk | Sort-Object - Property number | Select - Last 1 - ExpandProperty number)
153+ $diskNum = (get-disk | Sort-Object - Property number | Select-Object - Last 1 - ExpandProperty number)
153154while ($diskNum -eq $totaldisks -and $counter -lt $maxRetries )
154155{
155156
156157 Write-host ' retry..'
157158 $counter += 1
158159 Start-Sleep - Seconds 10
159- $diskNum = (get-disk | Sort-Object - Property number | Select - Last 1 - ExpandProperty number)
160+ $diskNum = (get-disk | Sort-Object - Property number | Select-Object - Last 1 - ExpandProperty number)
160161}
161162
162163if ($counter -eq $maxRetries )
0 commit comments