To manage local groups, you can think about using net.exe. It may be much easier than using COM interfaces. The next line will add a local user account to the local Administrators group: net localgroup Administrators Tobias /ADD This functionality may...

Office365 comes with a complete set of PowerShell cmdlets. To review the cmdlets and what you can do with them, visit this URL: http://onlinehelp.microsoft.com/en-us/office365-enterprises/hh125002.aspx ReTweet this Tip!

To extract an icon from a file, use .NET Framework methods. Here is a sample that extracts all icons from all exe files in your Windows folder (or one of its subfolders) and puts them into a separate folder: [ System.Reflection.Assembly ] :: LoadWithPartialName...

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 = New-Object -ComObject Microsoft.Update.Session $Searcher = $Session . CreateUpdateSearcher () $HistoryCount =...

Whenever you use Invoke-Command to remotely execute code, you will notice that PowerShell automatically adds the column PSComputerName to your results. That's great because when you run Invoke-Command against more than one computer, you want to still...

Assume your function wanted to know whether it is the last element in a pipeline or operating in the middle of it. Here is a way for a function to determine its current pipeline position: function test { param ( [ Parameter ( ValueFromPipeline = $true...

In a previous tip you learned how you can forward function parameters to cmdlets. But what if you just want to forward some of the parameters? Here is a sample: function Get - BIOS ( $ComputerName , $Credential , [ switch ] $Verbose ) { $a = $global:psboundparameters...

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: Get-History -Count $MaximumHistoryCount | ForEach-Object { $_ . CommandLine | Out-File $env:temp\myscript.ps1 -Append...

Here is a piece of code that will create a local user account and put it into the local Administrators group: $computername = $env:computername # place computername here for remote access $username = ' AdminAccount1 ' $password = ' topSecret...

In a previous tip, we showed you how to create a new local admin account using ADSI. On Windows 7 and Server 2008, it is much easier to use net.exe instead: net user AdminAccount1 /ADD net localgroup Administrators AdminAccount1 /ADD ReTweet this Tip...

Many cmdlets have a built-in -ComputerName parameter that will allow for remote access without using the new PowerShell remoting. For this to work, your firewall will need to be adjusted on the target machine: In addition, some cmdlets (like Get-Service...