PowerShell - Svet Paregov https://paregov.net Svetoslav (Svet) Paregov's Personal Web Site Wed, 27 Nov 2019 04:44:38 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.4 https://paregov.net/wp-content/uploads/2019/11/cropped-site_icon_512x512-32x32.png PowerShell - Svet Paregov https://paregov.net 32 32 169379028 Get values of all the properties of a PowerShell object https://paregov.net/get-values-of-all-the-properties-of-a-powershell-object/?utm_source=rss&utm_medium=rss&utm_campaign=get-values-of-all-the-properties-of-a-powershell-object Fri, 23 Dec 2016 02:42:00 +0000 https://paregov.net/?p=6563 Lets say you want to list all properties of an object but you don’t know all of them by name. Here is comming in help the Get-Member cmdlet. I find it very useful especially when working with new objects that I’m not familiar with.

I’m going to give an example with the list of network adapters listed from the WMI.

 So, lets list all of the members.

Get-Wmiobject Win32_NetworkAdapter | where { $_.Speed -ne $null -and $_.MACAddress -ne $null } 

…

The post Get values of all the properties of a PowerShell object first appeared on Svet Paregov.

]]>
Lets say you want to list all properties of an object but you don’t know all of them by name. Here is comming in help the Get-Member cmdlet. I find it very useful especially when working with new objects that I’m not familiar with.

I’m going to give an example with the list of network adapters listed from the WMI.

 So, lets list all of the members.

Get-Wmiobject Win32_NetworkAdapter | where { $_.Speed -ne $null -and $_.MACAddress -ne $null } 
…

The post Get values of all the properties of a PowerShell object first appeared on Svet Paregov.

]]>
6563
XSLT processor with PowerShell https://paregov.net/xslt-processor-with-powershell/?utm_source=rss&utm_medium=rss&utm_campaign=xslt-processor-with-powershell Sat, 18 Jul 2015 01:46:00 +0000 https://paregov.net/?p=6566 Here is a simple way to transform XML document with specified XSL in PowerShell. It is easy achieavable using the System.Xml.Xsl namespace of the .NET.

PARAM
(
    [Parameter(Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [String]$XmlPath,
     
    [Parameter(Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [String]$XslPath,
     
    [Parameter(Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [String]$HtmlOutput
)
 
try
{
    $XslPatht = New-Object System.Xml.Xsl.XslCompiledTransform
    $XslPatht.Load($XslPath)
    $XslPatht.Transform($XmlPath, $HtmlOutput)
     
    Write-Host "Generated output is on path: $HtmlOutput"
}
catch
{
    Write-Host $_.Exception -ForegroundColor Red
}

We pass the path to the XML file and the path to the …

The post XSLT processor with PowerShell first appeared on Svet Paregov.

]]>
Here is a simple way to transform XML document with specified XSL in PowerShell. It is easy achieavable using the System.Xml.Xsl namespace of the .NET.

PARAM
(
    [Parameter(Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [String]$XmlPath,
     
    [Parameter(Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [String]$XslPath,
     
    [Parameter(Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [String]$HtmlOutput
)
 
try
{
    $XslPatht = New-Object System.Xml.Xsl.XslCompiledTransform
    $XslPatht.Load($XslPath)
    $XslPatht.Transform($XmlPath, $HtmlOutput)
     
    Write-Host "Generated output is on path: $HtmlOutput"
}
catch
{
    Write-Host $_.Exception -ForegroundColor Red
}

We pass the path to the XML file and the path to the …

The post XSLT processor with PowerShell first appeared on Svet Paregov.

]]>
6566
PowerShell 2.0 and Write-Verbose strange behaviour https://paregov.net/powershell-2-0-and-write-verbose-strange-behaviour/?utm_source=rss&utm_medium=rss&utm_campaign=powershell-2-0-and-write-verbose-strange-behaviour Sat, 30 Aug 2014 01:49:00 +0000 https://paregov.net/?p=6568 I was writting a script for work wich was invoked on Windows 2012 R2 with PowerShell 4.0 as well on Windows 2008 R2 with PowerShell 2.0. This script was calling some sg utils and comparing the results. There is option to call it and to get just the result or to call it with more messges to see what actually is doing. So Write-Verbose seemed as a perfect option. In the first case all works fine with PowerShell (PS) 4.0. …

The post PowerShell 2.0 and Write-Verbose strange behaviour first appeared on Svet Paregov.

]]>
I was writting a script for work wich was invoked on Windows 2012 R2 with PowerShell 4.0 as well on Windows 2008 R2 with PowerShell 2.0. This script was calling some sg utils and comparing the results. There is option to call it and to get just the result or to call it with more messges to see what actually is doing. So Write-Verbose seemed as a perfect option. In the first case all works fine with PowerShell (PS) 4.0. …

The post PowerShell 2.0 and Write-Verbose strange behaviour first appeared on Svet Paregov.

]]>
6568