Hello everybody,
i Need your help. our Company Needs to add custom properties automaticly.
Is it possible to add custom properties to a node polling a registry key?
Kind regards
thanks for your post:
we create a PowerShell script that works fine:
############################################################# ## Powershell Script für Import Custom Properties in ORION ## ## Autor: Tobias Möller ## Version: 1.0 ## Datumsverion: 2020-03-25 ## #############################################################
# Funktions Definitionen ### GUID-IP Berechnen ##function ip2guid($ip){$ipx = @()foreach ($ipa in $ip.split(".")){$ipx += "{0:X2}" -f [int]$ipa #Hex}$ipy = $ipx[3] + $ipx[2] + $ipx[1] + $ipx[0] + "-0000-0000-0000-000000000000"$ipy = $ipy.replace(' ', '')return($ipy)}## ENDE GUID-IP Berechnen ##
# ENDE Funktionendefinition #
# SWIS Snapin in Powershell laden um Solarwinds Funktionen bereit zu stellen #if (!(Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {Add-PSSnapin "SwisSnapin"}# ENDE SWIS Snapin laden #
# Variablen Definitionen #Clear-Variable Errorlist -ErrorAction SilentlyContinueClear-Variable ERRORCSV -ErrorAction SilentlyContinue## Orion System ##$hostname = ""$username = ""$password = ""$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))$target = Connect-Swis -Credential $cred -Hostname $hostname$targetv2 = Connect-Swis -v2 -Credential $cred -Hostname $hostname$SystemName = ''$Errorlist = @()## ENDE Orion System ##
## Email System und Email Inhalte ##$SMTPServer=""$MailFrom=""$Subject="Report - Import Custom Properties"$MailRecipent=""$MailRecipent2=""$MailRecipent3=""$MailBody=""## ENDE Email System und Email Inhalte ##
## Datums und Zeitvariablen ##$a = Get-Date$Jahr = $a.Year$Monat = $a.Month$Tag = $a.Day$Stunden = $a.Hours$Minuten = $a.Minutes$Sekunden = $a.Seconds$FileDate = $a.ToString("yyyy-MM-dd")## ENDE Datums und Zeitvariablen #### Löschskript Kriterien (löscht CSV Dateien älter als X Tage) ##$Now = Get-Date$DaysToKeep = '4'$TargetFolder = ''$Extension = '*.csv*'$LastWrite = $Now.AddDays(-$DaysToKeep)## Löschskript Kriterien (löscht CSV Dateien älter als X Tage) ##### LogFile Variablen ###$CSVPath"### Ende LogFile Variablen ###### Abrufen aller Windows Nodes in Solarwinds ###$AlleNodes = Get-SwisData $target "Select URI,DNS,Nodes.CustomProperties.URI AS CPURI from Orion.Nodes where Vendor='Windows'"foreach($Node in $AlleNodes){$CPURI=$Node.CPURI$DNSName=$Node.DNSif (($DNSName -notmatch '') -and ($DNSName -ne '') ) {#write-host $DNSNametry {$NodeResult= New-Object psobject$RegValue= Invoke-Command -ComputerName $DNSName -ScriptBlock {(Get-ItemProperty -Path HKLM:\SOFTWARE\).CustomProperty} -ErrorAction StopWrite-Host $RegValueWrite-Host "$DNSName : OK"#$RegValue | gm$NodeResult | Add-Member -type NoteProperty -Name Server -Value $DNSName$NodeResult | Add-Member -type NoteProperty -Name Message -value $RegValue$SETCP=@{Syna_CustomProperty=$RegValue}Set-SwisObject $target $CPURI $SETCP$Errorlist += $NodeResult}catch {
#($error.Exception.Message.tostring()) | gmwrite-host "Fehler $DNSName"# $ERRORCSV=$Error.Exception.Message$ERRORCSV="RegKey konnte nicht abgefragt werden"#$ERRORCSV | gm#$ERRORCSV$CPURI=""$NodeResult | Add-Member -type NoteProperty -Name Server -Value $DNSName$NodeResult | Add-Member -type NoteProperty -Name Message -value "$ERRORCSV"$Errorlist += $NodeResult}#end catch#####hinzufügen Mail bei Fehlern.
}#end if
}#end foreach
# $Errorlist | ft -AutoSize#$Errorlist | gm#### Exportieren der Ergebnisse ####$Errorlist | Export-csv -Path $CSVPath -Delimiter 9 -NoClobber -NoTypeInformation -Append -Encoding Unicode
#### Report E-Mail versenden ####Send-MailMessage -Attachments $CSVPath -Body $MailBody -From $MailFrom -SmtpServer $SMTPServer -Subject $Subject -To $MailRecipent,$MailRecipent2,$MailRecipent3 -BodyAsHtml
#Clear Variable$Errorlist = $nullClear-Variable Errorlist -ErrorAction SilentlyContinue$Errorlist
Hello,
Custom properties can be defined as mandatory. If I understand your requirement you may need to consider some method of automation similar to what is outlined here TC18: Creating and Updating Orion Custom Properties with PowerShell
Impressive solution, thank you for sharing!