Posts tagged Powershell

Manage test and production groups in WSUS from powershell with PoshWSUS

I have always found the WSUS interface lacking in functionality for handling multiple server groups with test and production environments and here comes PoshWSUS in real handy.

I will show you basics on how to manage test and production groups and verify patch assignment.

You can find the PoshWSUS module here

Loading the module and connecting to your WSUS server

Select the group for your test environment that already got the latest patches assigned and deployed where patch functionality is verified

Get all the patches from your test environment and assign them to your production group

When the script is done running you will have an output list on all the assigned patches to the production group.

Lets verify that the production environment has the same patches applied as the test environment and list missing patches if found

If no patches are returned then your test environment now match your production environment of assigned patches

 

 

Bulk Creation of Room mailboxes Using Powershell

0

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.

mbxident

“r164:\Calendar”

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.

 

/Nike

Install and uninstall Java through Powershell – SCCM

0

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

0

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

0

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

Export and import wireless profiles through powershell

0

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

 

EXPORT

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

 

IMPORT

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.

Password Expire Mail Script

0

We had a issue at work where all the webmail users called in the same weeks as there passwords was about to expire, they didnt get any notification since they never logon on to a computer, and don’t forget that Windows 7 users dont get the same change password promt as the XP users get, now its just a small notification balloon. Thought this issue would be solved by a quick search for a script on google but didnt find any good ones around that covered all aspects.

There are alot of scripts that gets all users where password is about to expire but they only do the query against one domain, password expire dont replicate as often as needed to just be able to query one DC.

I needed a script that collected all users that are enabled and password was about to expire from all domain so this is what I came up with.

Done, just schedule this script and get rid of all help-desk calls disturbing your morning coffee!

Lync 2010 – Add AD users to Lync through Powershell

0

Here is a script to add AD users automaticly to Lync 2010

This is the simple way of adding every AD user that isnt allready enabled for Lync 2010:

This is the more controlled option if you have a bigger and more complex environment:

If you plan to use the second one or the last one make sure that you have Quest AD commands module installed.

This is the one that I use at my domain

Remove all mapped printers from a specific printserver in powershell

0

I was working on a print-migration and needed to remove all mapped printers to the old print server on all clients. I made this script and placed it under login script in the same GPO as the new distributed printer GPO. This way then the new printers will be deployed for all users the old ones will automatically be removed.

Change the “\PRINT-SERVER” in the script to your print-server and the script will remove all mapped printers that contain that print-server path.

Done, now all your mapped printers that contained the path entered will be deleted!

NZB Cleanup script

0

A friend wanted me to make a powershell script to clean up his NZB movie/series directory from crap files and sample video as they just take place so since i did a little script for that I might as well share it even if its a basic one.

This script will remove the following files: .sfv , .nfo , nzb and par2 files that might have been missed by the NZB download client.

Just exchange the paths to your own nzb download(s) directory.

Just make the windows scheduler run the script at night and you will always have a nice movie repository =)

Page 1 of 212
Go to Top