I am attempting to leverage Powershell to update custom properties of a batch of nodes with no consistent IP schemes. I am fairly new to Powershell, but I have a script working to change custom properties of a single IP. I was hoping I could create a text file and somewhere in the script reference the text file of IPs.
Here's the script:
#Intialization
Add-PSSNapin SwisSnapin
# Connect to SWIS
$hostname = "x.x.x.x"
$username = "username"
$password = get-content Path\To\PWinfo.txt | convertto-securestring
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
$swis = Connect-Swis -host $hostname -cred $cred
# prepare a custom property value
$customProps = @{
Address=" "
ASRN=" "
AssetTag=" "
CircuitID=" "
City=" "
Comments=" "
ConfiguredBy=" "
Department=" "
ESN=" "
FourthSiteEmail=" "
InServiceDate=" "
PONumber=" "
PurchaseDate=" "
PurchasePrice=" "
Recorder_Type=" "
SecondarySiteEmail=" "
SiteEmail=" "
TertiarySiteEmail=" "
Tower_Location=" "
}
# set the custom property
$uris = Get-SwisData $swis "SELECT Nodes.CustomProperties.Uri FROM Orion.Nodes WHERE IP_Address LIKE 'x.x.x.x'"
$uris | Set-SwisObject $swis -Properties $customProps
Where would I inject the get-content file to be referenced? Thanks in advance!