Examples/Ravello-Framework.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Framework to work with the Ravello module

#region Start
$workDomain = 'work.domain'
$workProxy = 'http://proxy.work.domain:8080'
$workCredentials = "$($env:USERPROFILE)\workRavelloCreds.csv"
$homeCredentials = "$($env:USERPROFILE)\homeRavelloCreds.csv"

# Work
if($env:USERDOMAIN -match $workDomain){
  $obj = Import-Csv -Path $workCredentials -UseCulture
  $sPswd = ConvertTo-SecureString -String $obj.Pswd -AsPlainText -Force
  $cred = New-Object System.Management.Automation.PSCredential ($obj.User, $sPswd)
  $connect = Connect-Ravello -Credential $cred -Proxy $workProxy
}
# Home
else{
  $obj = Import-Csv -Path $homeCredentials -UseCulture
  $sPswd = ConvertTo-SecureString -String $obj.Pswd -AsPlainText -Force
  $cred = New-Object System.Management.Automation.PSCredential ($obj.User, $sPswd)
  $connect = Connect-Ravello -Credential $cred
}
#endregion

#region Your Ravello Automation Script

#endregion

#region Stop
Disconnect-Ravello -Confirm:$false
#endregion