Backup all GPO in domain through Powershell


Bulk Creation of Room mailboxes Using Powershell


The question came during a meeting, who want’s to be responsible for creating the room mailboxes? I figured it would be interesting to brush up on powershell so I grabbed it. I started of creating a csv file containing the following headers.


Displayname, UserPrincipalName,Office,ResourceCapacity,OrganizationalUnit


Regarding Office, this is what shows up in the addresslist so if you have several locations it is a good idea to populate this property. When the csv file was ready (make sure it’s comma-seperated, not semicolon) I ran the following command.

import-csv [pathtocsv] | foreach-object {new-mailbox -Name $_.DisplayName -DisplayName $_.DisplayName -UserPrincipalName $_.UserPrincipalName -Office $_.Office -ResourceCapacity $_.ResourceCapacity -OrganizationalUnit $_.OrganizatinalUnit -Room}


Since the Rooms are not active until a couple of weeks I ran the following command to hide them from the addresslists. this csv contained the alias of the room mailboxes.

import-csv [pathtocsv] | foreach-object {set-mailboxfolderpermission -Identity $_.Alias -HiddenFromAddressListsEnabled $true}


Since I want all users to see who the meeting organizer is I created one more csv file containing the alias of the rooms and added the following tail.



import-csv [pathtocsv] | foreach-object {set-mailboxfolderpermission $_.mbxident -User Default -AccessRights ReadItems}


Looking back you could put all values in the same csv file to prepare everything before you run the commands, the csv file would then look something like this.

Displayname, UserPrincipalName,Office,ResourceCapacity,OrganizationalUnit,Alias,mbxident


When formating the csv file dont forget to put ” ” if you have spaces and make sure you dont have trailing white spaces.



Add multiple Windows patches to WIM using DISM and Powershell


Install and uninstall Java through Powershell – SCCM


I needed to deploy Java in one of our enterprise environments with a lot of old Java still laying around, I needed to upgrade all to the new version and remove all old versions as they are a security threat. Java don’t have the option to remove all previous installations, I guess its because its a shitty software, but what do I know.

Here is my solution to remove all previous Java installations and install the new Java

SCCM and Adobe Reader XI with Powershell


How to distribute Adobe Reader XI in System Center

1. Download the .msi package from adobe  here

2. Download the Adobe Customization Wizard XI here

3. Do you customization to fit your IT needs in Customization Wizard and generate a .mst file

4. Create a powershell file with the following code

Uninstall a program from powershell


If you need to uninstall a program from a prowershell script this will do the trick:

If you get the return value of 1603 your not running your script as admin

SCCM 2007 and Powershell Packages


Dont you just hate problems that are fixed by one easy click but finding what to change takes forever. I had a problem with a task sequence for a new laptop model that refused to execute packages using powershell. The older sequences executed fine and I could not understand why. At first I started looking at the powershell executionpolicy and realized I had forgotten to add the commandline that set it to RemoteSigned in the sequence. Easy fix, I added the commandline in the sequence and ran the sequence again…..all powershell packages failed.


After this failure I tried running the package commandline manually and it worked fine. All the packages installed without a problem. I started looking at smsts.log and execmgr.log and could not find anything pointing me to what was going wrong until I compared the logs to another model that actually could run these packages. I noticed that the older sequence downloaded the files and executed them locally but the new one executed from the UNC path. This led me to the advertisement of the task sequence, and there it was right in front of my eyes. I had forgot to set the advertisment correct so it did not download the packages before executing them.




Easy fix but took forever to find!


// Nike

ESX – Shutdown virtual machines on specific hosts through powershell


We needed a powershell script at work to shutdown specific hosts and there vm at power-failure, this is what I came up with.

Notice: You need to install PowerCLI from VM to get this to work as the script uses PowerCLI as a snapin and if you are planing on using this script on another machine then the VSphere server you need a valid certificate on the VSphere server to get this to work.

Microsoft Exchange 2010 – EWS and big attachments


If you need to send big attachments with your MAC clients you need to change the default value for Microsoft Exchange 2010 which is set to 10MB/35MB (First release / SP1)

There are a few steps on how to get this to work, you need to change the file for your entire IIS environment, allowing the RequestFiltering to be changed and then change the actual value for  maxReceivedMessageSize and maxAllowedContentLength.



1. Change your file in “C:WindowsSystem32Inetsrvconfigapplicationhost.config” to allow requestFiltering override to Allow

2. Change your web.config located in “C:Program FilesMicrosoftExchange ServerV14ClientAccessexchwebews” to your new value. If you want to be able to send about 50MB attachments you should change the value to about 85MB as converting to MIME plays a part in this aswell. This value need to be changed on all your bindings that you are going to use, or just change them all to make it easy.

3. And then change your maxAllowedContentLength to the same value as above

4. Run the following command to make it stick after updates (Not sure if this really is needed but It wont hurt)

Start a cmd promt as admin and go to “%windir%system32inetsrv” and then run the following command:


5. Make a restart of your IIS and you should be up and running sending big attachments.


Export and import wireless profiles through powershell


I needed to be able to push out wireless connections through sccm and this is what I came up with.



1. We need to export the wireless profile from a connected computer

2. Open the .xml file that was created in the previous step

3. Change the value protected from true to false

4. Enter your password for the wireless connection under keyMaterial, right now you will find a long string so just delete that and enter your password

5. Save and close

Now you have exported a profile and configured it with the password, the password is now in clear-text so this file should be kept in a secure place



1. Import the profile on the new computer, default is for current/all users


Done, now you have imported the wireless profile and you can now connect without entering a password.

But we dont want to import the profile manually, so now its time to automate this through powershell

1. We need to get the current directory where the script is running from

2. Import the wireless profile

3. Save your .pst file in the same directory as “Your Wireless Profile Name.xml” and just run your script from any source like usb, network share or whatever.

Page 2 of 3123
Go to Top