[Script Powershell] Connettersi sugli StorSimple serie 8000

Avendo avuto necessità di connettermi tramite Powershell sugli apparati StorSimple serie 8000 tramite HTTP, ho cercato uno script che mi permettesse di automatizzare la connessione.
Mi sono imbattutto nello script di Sam Boutros ma al momento di settare nei Trusted Host l’indirizzo dello StorSimple mi veniva restituito il seguente errore:
Set-Item : Cannot convert ‘System.Object[]’ to the type ‘System.String’ required by the parameter. Specified method is not supported.

Ho quindi modificato lo script come segue:
$StorSimpleIP = get-content -path .\IPStorSimple.txt

foreach ($address in $StorSimpleIP) {set-item wsman:\localhost\Client\TrustedHosts -Value $address.ToString() -Force}

# Get pwd for SSAdmin, store in encrypted local file for future automation
if (!(Test-Path -Path “.\SSCred.txt”)) {
Read-Host ‘Enter the pwd for your StorSimple administration’ -AsSecureString | ConvertFrom-SecureString | Out-File .\SSCred.txt
}
$Pwd = Get-Content .\SSCred.txt | ConvertTo-SecureString
$SSCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList “$StorSimpleIP\ssadmin”, $Pwd

$StorSimpleSession = Get-PSSession | where { $_.ComputerName -eq $StorSimpleIP }
if (! $StorSimpleSession) { $StorSimpleSession = New-PSSession -ComputerName $StorSimpleIP -Credential $SSCred -ConfigurationName SSAdminConsole }
$StorSimpleSession

Enter-pssession -credential $SSCred -ConfigurationName SSAdminConsole -ComputerName $StorSimpleIP

ScriptConnectStorSimple

Liked this post? Follow this blog to get more. 

Rispondi

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.