Powershell function for enabling a user for Lync and configure settings

A little while ago I posted a script for enabling users for Lync and settings some settings for that user. That script has been used here ever since I posted it and it has worked like a charm. However there’s always room for improvement, right?. So I have made a function out of it and for the first time (I think) I have even implemented some error handling. The function is also improved quit a bit on the help section and the info that is shown to the user after the function completes....

October 4, 2012 · nerenther

Powershell function for rotating event logs

A friend of mine came to me with an interesting powershell challenge today: how can I use powershell to archive and clear event logs? Well, challenge accepted! The reason the challenge arose is due to maintenance he performs on a number of customer servers. Every month he saves each eventlog and clears it manually, a time consuming task if you have more than a few servers. So here’s what I came up with:...

September 6, 2012 · nerenther

Function for adding photo in Active Directory

I have always been careful to avoid the really advanced and cool stuff in Powershell, like functions, arrays and such. But as I created the last script it hit me that it would be really cool to have it in a command, like set-adphoto. After some googling I found that funtions aren’t hard at all! Basically all I really had to do with the ad photo import script was to add “function Set-ADPhoto { ” in front of the script and end it with a }...

August 24, 2012 · nerenther

Check if DAG databases is on preferred server

If you are using DAG in exchange 2010 for high availability on your mailboxes there may be one thing you might have noticed, the databases can fail over to a less preferred server at any time without you noticing. Microsoft have provided you with a script for balancing these databases, RedistributeActiveDatabases.ps1. With this script you can activate the databases on their preferred server again. But how do you know when they have failed over?...

April 30, 2012 · nerenther

Redirecting a webpage using html

The redirect function in IIS 7 and 7.5 is in my experience pretty buggy. More often than not it will send the visitor into an eternal redirect loop. Because of that I have used this simple html code for redirecting, instead of using the built in function in IIS. Use it at your own will, I’m just posting it so I know where to find it the next time I need it 🙂...

February 27, 2012 · nerenther

Grep'ing the eventlog using powershell

If you are used to working with Linux you’re probably familiar with using tail, grep and such for gathering stuff from logs and other files. Those are quite useful tools and work very well when you want to find out e.g. why a user fails to log in. In Windows it’s a little different, if we want to find something in the event logs we have always had to resort to a console....

February 20, 2012 · nerenther

Mass import of users in Active Directory v2 – Powershell time

Earlier I posted a script that created users and homefolders and added the users to specified groups. It also set ntfs permissions on the homefolders. That script used primarily old fashioned stuff, so I sat down and started looking for a neat way to do the same in powershell. The powershell script I came up does a lot more than the last one. Here a little list: Creates OUs Creates users Creates security groups Creates distribution groups Creates mailboxes for all users Add specified users to the correct security and distribution groups Creates a homefolder root folder and shares it Creates a homefolder for each user and sets ntfs permissions Set storage limit on the exchange mailbox database As you can see, it does quite a lot....

October 27, 2011 · nerenther

Simple powershell script for enabling users for Lync

I wrote this simple little script for enabling users for Lync. It asks for input on name, sipdomain and line uri. The rest is set using variables defined at the start of the script. If you only have one sipdomain you can change the script so that it doesn’t ask for it. Here’s the script in all its glory: $UI = (Get-Host).UI.RawUI $UI.WindowTitle = "Enable lync user" Import-Module Lync #Setting some variables $registrarpool = lyncpool....

October 12, 2011 · nerenther

Install and configure Exchange 2010 using Powershell

In this guide I will show you how to install and configure a simple Exchange 2010 environment using no gui at all. Installing exchange 2010 without gui may seem kinda nerdy, but it’s quite useful for quickly setting up a test environment for example. Remember to run Windows update prior to the installation. Start powershell as administrator and type: import-module servermanager First we need to install all of the prerequisites:...

September 29, 2011 · nerenther

Setting NTFS permissions using Powershell

I am currently working on a script similar to the Mass import of users in Active Direcory post I published earlier (as promised 🙂 ). In the new script I wanted to only use powershell, so I had to find a way to set ntfs permissions using powershell. After all, the cacls way is pretty outdated. After some googling I came up with a rather extensive script, it is a little more complicated than I wanted but here goes:...

September 23, 2011 · nerenther