List of all colors available for PowerShell?

Pretty grid $colors = [enum]::GetValues([System.ConsoleColor]) Foreach ($bgcolor in $colors){ Foreach ($fgcolor in $colors) { Write-Host “$fgcolor|” -ForegroundColor $fgcolor -BackgroundColor $bgcolor -NoNewLine } Write-Host ” on $bgcolor” } Updated colours in newer powershell: https://gist.github.com/timabell/cc9ca76964b59b2a54e91bda3665499e

Web.Config transforms outside of Microsoft MSBuild?

I created a small function to handle Microsoft’s XML Document Transform in PowerShell. I copied the Microsoft.Web.XmlTransform.dll file from Visual Studio build folder to my script’s path, but you can reference it from the source folder if you’d like. function XmlDocTransform($xml, $xdt) { if (!$xml -or !(Test-Path -path $xml -PathType Leaf)) { throw “File not … Read more

How can I extract “Path to executable” of all services with PowerShell

I think you’ll need to resort to WMI: Get-WmiObject win32_service | ?{$_.Name -like ‘*sql*’} | select Name, DisplayName, State, PathName Update If you want to perform some manipulation on the selected data, you can use calculated properties as described here. For example if you just wanted the text within quotes for the Pathname, you could … Read more

PowerShell The term is not recognized as cmdlet function script file or operable program

You first have to ‘dot’ source the script, so for you : . .\Get-NetworkStatistics.ps1 The first ‘dot’ asks PowerShell to load the script file into your PowerShell environment, not to start it. You should also use set-ExecutionPolicy Unrestricted or set-ExecutionPolicy AllSigned see(the Execution Policy instructions).