powertips

Listing Windows Updates

There is a not widely known COM object that you can use to list all the installed Windows Updates on a machine. Here is the code: $Session =...

read more

Saving History to Script

PowerShell is all about trial and error, and when you want to save your interactive input to a script file, this is how it could be done:...

read more

Clean your TEMP folder!

When disk space gets low, you may want to clean up your temporary folder. The code deletes all files that are older than 30 days to make sure...

read more

Office365 Cmdlets

Office365 comes with a complete set of PowerShell cmdlets. To review the cmdlets and what you can do with them, visit this URL:...

read more

Forwarding Parameters

To forward function parameters to a cmdlet, use $psboundparameters automatic variable and splatting. Here is a sample: function...

read more

Creating Local Admins

Here is a piece of code that will create a local user account and put it into the local Administrators group: $computername = $env:computername #...

read more

Bulk Renaming Files

Rename-Item can rename hundreds of files in one step. Have a look: $global:i = 1 dir c:\test1\ -Filter cover*.jpg | Rename-Item -NewName {...

read more

Monitoring Folder Content

You can use a FileSystemWatcher object to monitor a folder and write a log for all newly created files. For example, this can be used as an...

read more

Renaming Computers

PowerShell can also rename computers. The next example will read the serial number from the system enclosure class and rename the computer...

read more

Return Arrays

Normally, PowerShell will not preserve the type of an array returned by a function. It is always reduced to Object[]: function test {...

read more
1 90 91 92 93 94 122