-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1_meh.ps1
26 lines (20 loc) · 937 Bytes
/
1_meh.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
Clear-Host
Import-Module .\secrets.psm1 -force
Import-Module SwisPowerShell
$hostname = 'se-orion01.emea.sales'
$text = ".\encrypted_password1.txt"
$cred = get-credentialusingpasswordfromfile ( $text)
#Build the connection to the HCO server
$swis = Connect-Swis -Credential $cred -Hostname $hostname
#make sure it's reset before starting!
reset-unmanagednodes($swis)
#Get a list of nodeids, based on a custom property
$swql = 'SELECT nodeid from orion.nodes n where n.CustomProperties.ToUnmanage = "True" '
$ids = Get-SwisData -SwisConnection $swis -query $swql
#set start and end time
$StartTime = (Get-Date).ToUniversalTime()
$EndTime = (Get-Date).ToUniversalTime().AddHours(1)
#cycle through IDs, and call invoke-swis to unmanage each one
ForEach ($id in $ids){
Invoke-SwisVerb -SwisConnection $swis -EntityName Orion.Nodes -verb Unmanage @("N:$Id",$StartTime,$EndTime, $false) | Out-Null
}