Tag: powershell

-ShowWindow in Powershell help

The adage, you learn something new everyday is very true.

I’m reading a book called Learn Powershell in a Month of Lunches by Don Jones and Jeff Hicks and I just discovered a helpful nugget I didn’t know existed, -ShowWindow.

Example:
help Get-ADGroupMember -showwindow

The -ShowWindow parameter will give you a popup window with the help topic you’re researching.  You can search words and phrases within the help topic. The found term is highlighted for easy reading and you can move between terms using the previous and next buttons. The window can be resized and you can increase or decrease the text with the slider at the bottom of the window. The description is a bit shorter for some cmdlets, but there are even some command examples displayed in the help window to get you going without coming out of your prompt.

The PowerShell help window
-ShowWindow

Gone are the days of opening a second Powershell window to reference the help while crafting command line syntax. -ShowWindow is a great too in the Powershell arsenal.

 

~Note~ This works differently in PS 4.0 and 5.0. and within different builds of Windows 10. 
Some contents are missing or out of order. It appears it is a known issue.
Your mileage may vary.

A curved arrow pointing right Don’t forget Help Cmdletname -online It launches help in the browser. Keeping you in your PS window without taking you away from your prompt.

 

User Powershell to test a password

Sometimes you need to test to make sure you’re entering the correct the right password. Be it a service account while installing a app or testing a password reset.

The start-process cmdlet is used to start one or more processes on a local computer. Get-Credential gets an object based on username and password. Use it to open an application and test the credentials.

Open a Powershell prompt:

start-process notepad.exe -credential (Get-Credential acme\johnquser)

start-process

Enter the credentials you’re trying to test. If you’re correct, notepad will open.

enterpassword

notepad

If not, a password reset is in order.

 

 

Powershell Script with Spaces in the Path

I’ve been trying to write this script that has a path to a .dll with a space in it. Every example I came upon either used single quotes, double quotes or nothing at all.

I tried

Import-Module -name 'c:\program files\EqualLogic\bin\EqlPSTools.dll'

and

Import-Module -name "c:\program files\EqualLogic\bin\EqlPSTools.dll"

There are 2 ways that worked:

Import-Module -name c:\program` files\EqualLogic\bin\EqlPSTools.dll

Using the back tick character, below the tilde on a Windows keyboard. Not to be confused with the opening single quote.

keyboard

and

Import-Module -name ("c:\program files\EqualLogic\bin\EqlPSTools.dll")

For more on commonly confused characters, check out this page.

Social media & sharing icons powered by UltimatelySocial