Tag Archives: PowerShell

Exchange PowerShell: How to Bulk Import/Create Mail Contacts

Exchange2013 PowerShell

I’ve been working a lot with Exchange 2013 recently so will be focusing my next few posts on some PowerShell I have used and found useful to help me setup an Exchange 2013 environment for a new company.

In this post I will look at the process I used to bulk create Contacts.

Continue reading

PowerShell: How to add all users in an OU to a Security Group using Get-ADUser and Add-ADGroupMember

PowerShellI’m currently setting up a new system for a client and wanted to add all users in a specific Organisational Unit (OU) to a specific Security Group.

I’ve written about Get-ADUser a few times before, so by combining that with another PowerShell cmdlet Add-ADGroupMember to add users to a group we should be in business!

In this example we’ll add users in the OU Head Office to the SSLVPN Users Security Group.

Continue reading

PowerShell: How to clean up the WinSxS folder in Windows Server 2012 R2

Windows Server 2012 R2

In this post we’ll look at how to use PowerShell to reduce the size of the WinSxS folder in Windows Server 2012 R2.

A customer has a very quick SSD based server at a cloud provider, but although it is SSD based it only has a tiny 40GB C:, which is a very small footprint for the OS, a couple of apps and logs files. So i was asked to take a look and see what i could do to make a bit of room.

The WinSxS folder contains the files for all the Windows Features you can install in the default operating system. Each time you run a windows update files in the WinSxS folder get update and the size will continue to grow.

Since Windows Server 2012 Microsoft have made it very easy to tidy the WinSxS folder up. They introduced a new feature called “Features on Demand”. Rather than the WinSxS containing all the binaries for all the features you could possibly install on the server, “Features on Demand” allows you to remove the files for features you aren’t using.

If at a later date you want to install a feature you have removed from the WinSxS folder you’ll need to specify a location for the source files.

Continue reading

PowerShell: Get-ADComputer to retrieve computer last logon date (and disable them) – part 2

PowerShell

In this article we’ll look at using Get-ADComputer and Set-ADComputer to list computer accounts which haven’t logged in for xx days, and then automatically disable them.

In part 1 we looked at how to use Get-ADComputer to list computers by name and sort them by their last logon date with the premise that we can use the information to remove historic computer accounts from the domain.

Now we know the computer accounts we want to work with we will look at modifying the PowerShell command to automatically disable them.

Continue reading

Exchange PowerShell: How to enumerate and modify Distribution Group properties

Exchange PowerShell

Here is another quick Exchange PowerShell post on distribution groups, in it we will look at how to check and modify a particular setting.

A client recently got in touch after a suspect email was sent to all staff in a particular distribution group. Usually only staff can send emails to distribution groups because you need to be authenticated, so I had a quick check of the distribution group’s settings to see what was going on.

Continue reading

Veeam PowerShell: How to schedule an inventory of a drive and mark the media as free

Since version 7 of Veeam Backup and Recovery I’ve started to use the new capability of backup to tape from within Veeam for offsite storage, rather than continue using Symantec Backup Exec to backup to tape.

Typically I’ll have a backup to disk job that runs a reverse incremental backup, and then I will use a backup to tape job to backup the Veeam configuration and vbk and vbm files from the Veeam repository, so that on each tape we have a full backup.

The downside to this is that you have to mark the tape media as free so that we can fit a full backup onto the tape, if this doesn’t happen the the Veeam backup wil go onto more than one tape and it makes managing the backups a bit more complex, espcially when end users are responsible for swapping the tapes over.

Below is a script that I’ve put together to run an inventory of the tape drive, and then mark the tape as free so that its full capacity can be used for backups. This assumes that you use a manual tape rotation, typically a Grandfather, Father, Son scheme.

Write-host “Prepare Tape for Veeam backup”
Add-PSSnapin -Name VeeamPSSnapin
Get-VBRTapedrive | Start-VBRTapeInventory
Get-VBRTapeMedium -Online | Erase-VBRTapeMedium -confirm:$false

Save the scripts as a ps1 file, and then use Task Scheduler to run it prior to the tape job starting.

EDIT(19/07/2014):

After further testing I’ve replace the last two lines of the original script:
$tape = Get-VBRTapeMedium -Online
Move-VBRTapeMedium -Medium $tape -MediaPool Free -Confirm:$false

With:
Get-VBRTapeMedium -Online | Erase-VBRTapeMedium -confirm:$false

Although moving the tape to the Free Media Pool, should allow the data to be overwritten I was finding backup jobs needing two tapes as it wasn’t overwriting the tape. By changing the last line to Erase-VBRTapeMedium the job runs a quick erase and leaves the tape in the current Media Pool.

Useful Links:

1. Veeam PowerShell Guide

2. Veeam PowerShell Forum

Related Posts:

1. Veeam Backup and Replication 7 – Patch 4 released

2. How to change the vPower NFS path in Veeam 7

3. How to view historic backup logs in Veeam 7

4. Veeam file level restore error – No disks have been mounted

5. ESXi 5.1 – VMware Tools – [warning] [vmusr:vmusr] Error in the RPC receive loop: RpcIn: Unable to Send.

PowerShell: Get-ADComputer to retrieve computer last logon date – part 1

PowerShellI’ve written about Get-ADUser several times already to find out Active Directory user information, but in this post we’ll be using Get-ADComputer to find out the last logon date for the computers in Active Directory.

As computers are retired or fail and are replaced how often do admins remember to remove the computer accounts from Active Directory?

You can use the command we are going to create below to enumerate the last login date for all the computer accounts in your domain, so that you can safely disable and remove them after they have been inactive for a period of time. Continue reading