Recent Discussions
Powershell in five easy steps
A few years ago, I wrote a powershell tutorial. Thought some may find it useful. On to the Future with Powershell – PowerShell.org It's less programming tutorial than other programming tutorials. I wrote it for the "you can tear this mouse from my cold hands" type of admin who are being forced to learn powershell to do their jobs. It's peppered with some nuggets of geeky humor to keep it rolling forward and is just enough to get someone started using powershell (or any other programming language) by focusing on the larger concepts of Storage, Input, Output, Decisions, Loops... the building blocks of every language from assembly to applescript.17Views1like0CommentsVM creation date info from Vsphere
Hi, I am trying to add an attribute forVM creation date on datasource:VMware_vSphere_VirtualMachinePerformance I tried to add below line in the Active Discovery script: 'auto.config.create_Date' : vmConfig?.createDate, But getting an error. Has anyone else already tried getting this property of the VM or knows a solution?88Views8likes0Commentsincreasing speed of 'Sources using Powershell Remote Sessions
TLDR: don't load session profiles when using Powershell Remote. Use an explicit pssession with the -nomachineprofile flag present. Several LM provided 'Sources use it. Many of the 'Sources I've written in the past use it as well. Here's the find/replace for the LM provided ones (find & replace are separated into comment regions): #region FIND try { #-----Determin the type of query to make----- # check to see if this is monitoring the localhost collector, as we will not need to authenticate. if ($hostname -like $collectorName) { $response = Invoke-Command -ScriptBlock $scriptBlock } # are wmi user/pass set -- e.g. are these device props either not substiuted or blank elseif (([string]::IsNullOrWhiteSpace($wmi_user) -and [string]::IsNullOrWhiteSpace($wmi_pass)) -or (($wmi_user -like '*WMI.USER*') -and ($wmi_pass -like '*WMI.PASS*'))) { # no $response = Invoke-Command -ComputerName $hostname -ScriptBlock $scriptBlock } else { # yes. convert user/password into a credential string $remote_pass = ConvertTo-SecureString -String $wmi_pass -AsPlainText -Force; $remote_credential = New-Object -typename System.Management.Automation.PSCredential -argumentlist $wmi_user, $remote_pass; $response = Invoke-Command -ComputerName $hostname -Credential $remote_credential -ScriptBlock $scriptBlock } exit 0 } catch { # exit code of non 0 will mean the script failed and not overwrite the instances that have already been found throw $Error[0].Exception exit 1 } #endregion #region REPLACE try { $option = New-PSSessionOption -NoMachineProfile #-----Determin the type of query to make----- if ($hostname -like $collectorName) { # check to see if this is monitoring the localhost collector, # as we will not need to authenticate. $session = new-pssession ` -SessionOption $option } elseif ( ([string]::IsNullOrWhiteSpace($wmi_user) ` -and [string]::IsNullOrWhiteSpace($wmi_pass)) ` -or ( ($wmi_user -like '*WMI.USER*') ` -and ($wmi_pass -like '*WMI.PASS*') ) ) { # are wmi user/pass set # -- e.g. are these device props either not substiuted or blank # no $session = new-pssession ` -computername $hostname ` -SessionOption $option } else { # yes. convert user/password into a credential string $remote_pass = ConvertTo-SecureString ` -String $wmi_pass ` -AsPlainText ` -Force; $remote_credential = New-Object ` -typename System.Management.Automation.PSCredential ` -argumentlist $wmi_user, $remote_pass; $session = new-pssession ` -computername $hostname ` -credential $remote_credential ` -SessionOption $option } $response = Invoke-Command ` -session $session ` -ScriptBlock $scriptBlock exit 0 } catch { # exit code of non 0 will mean the script failed and not overwrite the instances # that have already been found throw $Error[0].Exception exit 1 } #endregion p.s. the replacement code has the formatting I prefer. Feel free to change it to suit your whitespace/line length needs. Mine is a blend of every language I've ever used as I traditionally have been the only one looking at my code. I call my formatting method the "I have to fix this 2 years from now and have a half an hour to figure it out" format. generally, 1 specific function per line, sections that collapse into a single line to make it easier to work through the code. The first character of each line should inform how it relates to the line above it. spaces added to make neat functional columns of similar parts of the line (parameter name, variable). Most programmers hate the formatting I use, but it works for me. There are line continuation characters " `" to make it all fall into place.51Views6likes0CommentsPalo Alto data source to grab HA Interfaces stats improved.
Hello, We've noticed that the config source 'PaloAlto_FW_HA_Interface' that's published on LM repo (version 1.4) doesn't use the best logic to try both API variations. On newer versions of PA (>=10.2.x) the API call changes slightly (since they've placed the <counters> section in a different path). With that being said, the OOTB module was failing on PAs with >= version. We've added some logic there & we're now having the version in mind (making use of ##auto.entphysical.softwarerev## property) to define how the API call will look like. Tested on several versions & it works smoothly. We've published our version on the exchange (code: DL74FN). If it's unavailable there for some reason, you can grab ithere. Thank you!24Views0likes0CommentsPalo Alto config source to capture XML configuration improved.
Hello, We've noticed that the config source 'PaloAlto_FW_RunningConfigXML' that's published on LM repo (version 1.4) doesn't use the best logic to try both API variations. They're using an IF statement to capture errors after the 1st API attempt, however, the script raises an exception if it fails, which will cause the script to abort & never actually try the 2nd variation. Instead of an IF statement, this should be done with the try{}catch{} statement, this way it will attempt the 2nd variation if the 1st one fails. We've published our version on the exchange (code: 9A779T). If it's unavailable there for some reason, you can grab it here. Thank you!65Views0likes0Comments