Windows 8.1 or Server 2012 R2 Both Windows 8.1 and Server 2012 R2 come with a module called “PrintManagement”. It includes all cmdlets needed to manage local and remote printers. To list all print jobs on a given computer, first determine...

Windows 8.1 or Server 2012 R2 To update Group Policy settings on a remote machine, use Invoke-GPUpdate, and submit the name of the computer where you want the update to occur. Invoke-GPUpdate schedules the command “gpupdate” on the remote...

Windows 8.1 or Server 2012 R2 Both Windows 8.1 and Server 2012 R2 come with a module called “PrintManagement”. It includes all cmdlets needed to manage local and remote printers. Here is a sample script that installs a printer driver and a...

All PowerShell versions PowerShell uses short names for the most common .NET types. To see if there is a short name for a .NET type you are using, try this: PS> [System.Management.Automation.LanguagePrimitives]::ConvertTypeNameToPSTypeName("System...

PowerShell ISE 3.0 and later To turn PowerShell code to all uppercase letters in PowerShell ISE, select the text, then press CTRL+SHIFT+U. To turn text to all lowercase letters, press CTRL+U. ReTweet this Tip!

PowerShell Version 3 and later To permanently map a network drive, use New-PSDrive with the –Persist parameter. This parameter makes the drive visible outside PowerShell. To really create a persistent network drive, also make sure you add –Scope...

All Versions If your script wants to output warnings or error messages, you can use Write-Warning or Write-Error. Both cmdlets will use the default PowerShell colors for warnings and errors. However, the cmdlets will also apply a text template to your...

PowerShell 2.0 and later Here is a function that illustrates two things: it shows how you can limit a parameter to a given data type, and it shows how you can use a .NET method to turn IP addresses into machine names: function Resolve-IPAddress { param...

PowerShell 3.0 and later The PowerShell ISE supports line breakpoints only: they make the code stop once the debugger hits that particular line. You can toggle line breakpoints in the PowerShell ISE by pressing F9. Just make sure the script is saved....

All PowerShell Versions If you'd like to audit NTFS permissions on your file servers, here is a suggestion how you could start. This script scans the Windows folder recursively for subfolders. Simply replace $Path with another path to scan other areas...

All PowerShell versions Typically, NTFS permissions in the file system are inherited. You can, however, add explicit permissions to files and folders. To find out where inheritance was changed and direct security settings have been added, you can use...

All Versions Typically, to access COM objects, these objects need to register themselves in the Windows Registry, and PowerShell needs the registered ProgID string to load the object. Here is an example: $object = New-Object -ComObject Scripting.FileSystemObject...

PowerShell 3.0 and later When you use Get-ChildItem to list files, by default, hidden files are excluded. To include hidden files, use the –Force parameter: PS> Get-ChildItem -Path $home -Force To only list hidden files, use the -Hidden parameter...

GroupPolicy Module When you create a new Group Policy, you can set a comment (or description). There is no apparent way, however, to change the description later. Here is code that allows you to retrieve a group policy, then read and/or change the description...