11< powershell>
22# This script is used to install and configure FSx for Windows File Server
33# ### Process param ####
4- $secretId = " AWS secret ARN, e.g arn:aws:secretsmanager:us-east-1:111004784675 :secret:MySecret-TC5M70 "
5- $ip = " Fsx admin ip, e.g. 172.25.45.32 "
4+ $secretId = " AWS secret ARN, e.g arn:aws:secretsmanager:us-east-1:111222333444 :secret:MySecret-123456 "
5+ $ip = " Fsx admin ip, e.g. 111.22.33.44 "
66$volName = " Fsx volume name, e.g. iscsiVol"
77$volSize = " volume size in GB, e.g 100"
88$drive_letter = " drive letter to use, e.g. d"
@@ -24,13 +24,15 @@ function unInstall {
2424}
2525
2626# default values
27+ # All FSxN instances are created with the user 'fsxadmin' which can't be changed
28+ # The script will create a log file in the Administrator home directory
29+ # The script will create an uninstall script in the Administrator home directory
2730$user = " fsxadmin"
28- $currentDir = Get-Location
2931$currentLogPath = " C:\Users\Administrator\install.log"
3032$uninstallFile = " C:\Users\Administrator\uninstall.ps1"
3133
3234$password = Get-SECSecretValue - SecretId " $secretId " - Select " SecretString"
33-
35+
3436
3537if ( $password -eq $null -or $password -eq " " ) {
3638 Write-Output " Failed to get data from Secrets Manager, exiting..." >> $currentLogPath
@@ -41,7 +43,7 @@ if( $password -eq $null -or $password -eq "" ) {
4143Write-Output " Get data from Secrets Manager, successfully" >> $currentLogPath
4244write-host " Get data from Secrets Manager, successfully" - ForegroundColor Green
4345$totaldisks = (get-disk | Sort-Object - Property number | Select-Object - Last 1 - ExpandProperty number)
44-
46+
4547# ### Installing ONTAP module #####
4648$m = " NetApp.ONTAP"
4749$path = " HKLM:\Software\UserData"
@@ -59,7 +61,7 @@ if($runStep -eq 0 -or (Get-Module | Where-Object {$_.Name -ne $m})) {
5961 Write-Output " # FSXn uninstall:" >> $uninstallFile
6062 Write-Output " Installing/ Import ONTAP module" >> $currentLogPath
6163 Write-Host " Installing/ Import ONTAP module" - ForegroundColor Yellow
62-
64+
6365 if (Get-Module | Where-Object {$_.Name -ne ' NuGet' }) {
6466 Install-PackageProvider - Name NuGet - MinimumVersion 2.8 .5.201 - Force
6567 @ (" Uninstall-PackageProvider -Name NuGet -Force" ) + (Get-Content $uninstallFile ) | Set-Content $uninstallFile
@@ -76,7 +78,7 @@ if($runStep -eq 0 -or (Get-Module | Where-Object {$_.Name -ne $m})) {
7678 Write-Output " Import module $m ." >> $currentLogPath
7779 write-host " Import module $m ."
7880 Import-Module $m - Verbose
79- Set-ItemProperty - Path $path - Name $itemName - Value 1
81+ Set-ItemProperty - Path $path - Name $itemName - Value 1
8082 }
8183 else {
8284
@@ -86,7 +88,7 @@ if($runStep -eq 0 -or (Get-Module | Where-Object {$_.Name -ne $m})) {
8688 Write-Output " Import module $m ." >> $currentLogPath
8789 write-host " Import module $m ."
8890 Import-Module $m - Verbose
89- Set-ItemProperty - Path $path - Name $itemName - Value 1
91+ Set-ItemProperty - Path $path - Name $itemName - Value 1
9092 @ (" Uninstall-PackageProvider -Name $m -Force" ) + (Get-Content $uninstallFile ) | Set-Content $uninstallFile
9193 }
9294 else {
@@ -337,4 +339,4 @@ else {
337339 Write-Host " FSx disk already created" - ForegroundColor Green
338340}
339341Remove-Item - Path $uninstallFile - Force
340- < / powershell>
342+ < / powershell>
0 commit comments