28. November 2011 13:17
I had a need to routinely update the members of a security group in Active Directory. The users in an OU were to be added/removed from the security group on a scheduled basis.
- Import-Module ActiveDirectory
- Get-ADGroupMember -Identity "Some Security Group" | ForEach-Object { $Member = $_.SamAccountName; Remove-AdGroupMember -Identity "Some Security Group" -Members $Member -Confirm:$false }
- Get-User -OrganizationalUnit "Some OU" | ForEach-Object { Add-ADGroupMember -Identity "Some Security Group" -Members $_.SamAccountName }
This could be written into a powershell script file to be run on a schedule.
8ba0086f-ba76-4ab6-ba76-2dbaf88234ae|0|.0
9. November 2011 15:47
After I migrated my hundreds of users, I had some that were refusing to quit using the old webmail address. We were retiring the URL and therefore we couldn't just stick it on the new OWA server. To fix this, I disabled ActiveSync (for phones), OWA, and MAPI (for Outlook).
The code is as follows:
Get-Mailbox -OrganizationalUnit "Some OU" -DomainController "Some DC" | Set-CASMailbox -OWAEnable:$false -ActiveSyncEnabled:$false -MAPIEnabled:$false
A few days after this change, a couple of the stragglers relunctantly started using the new OWA.... and liked it. 
bafd668f-8b56-46a2-9b6b-1f8b311df1dc|0|.0
18. October 2011 18:56
Thie script below will impor all the .PST in a directory. NOTE: You MUST have the .PST name match the alias in the domain.
Get-ChildItem \\server\share\*.pst | foreach { $user = $_.BaseName; New-MailboxImportRequest -Mailbox $user -FilePath \\server\share\$user.pst -BadItemLimit 50 }
078d7edf-ab2f-4a5d-8323-516ddc4ebb43|0|.0
16. October 2011 17:57
In my previous post, I explained how to export a .CSV for each group in an OU. This gives you a .CSV for each group which is named the same as the group name.
- Some Group 1.csv
- Some Group 2.csv
- Some Group 3.csv
- Some Group N.csv
Now, I need to create those Groups in a new AD. Here is the script that I used:
Get-ChildItem | foreach { echo $_.Basename } | ForEach-Object { dsadd group -scope u "cn=$_,OU=Groups,OU=Some OU,DC=SubDomain,DC=Domain,DC=TLD" }
This script calls the program DSADD and passes it the correct name (minus the .csv) which is then used to create the Groups.
Next, we run a similar script that walks through those same .CSV's and adds the users to the group with the same name as the .CSV.
Get-ChildItem | foreach { $GN = $_.BaseName; Import-Csv $_ } | foreach { Add-ADGroupMember -Identity $GN -Members $_.SamAccountName }
This works wonderfully well if the column titled SamAccountName has the correct usernames in it.
1abc0c8e-5239-4dc7-8078-35e82b514503|0|.0
16. October 2011 16:52
This script will export a .CSV for each group in an OU. The CSV will be named the same as the group name.
Get-Group -OrganizationalUnit "Some OU" | ForEach-Object { Get-Group -Identity $_.Name | ForEach { $_.Members } | Get-User | Export-Csv ($_.Name + '.csv') }
Remember this script is designed to run on one line. Remove the linebreaks.
32501752-c458-47b0-990d-2b54f729e3c6|0|.0
16. October 2011 14:56
I needed to add users to groups by PowerShell and was having trouble finding examples how to do it. Here is how I figured it out.
First, you need a CSV of the users's logon names. My list came from the CSV from:
Get-DistributionGroupMember -Identity 'Some List' | Export-Csv 'list.csv'
The list generated above consisted of alot of fields. The only one I am interested in for this use is "Alias". Once I had the list generated from my old AD, I then ran:
Import-Csv 'list.csv' | ForEach-Object { Add-ADGroupMember -Identity "Some New Group Name" -Members $_.Alias }
Remember the script above needs to be a single line. I had to break it apart so it will fit in the blog format. It worked like a charm.
f88aee3e-b5bc-4c06-9a4c-0e994af30d7f|0|.0
16. October 2011 13:03
This script exports users from an OU to a CSV that can be used by other scripts. I had to move hundreds of users from one domain to another and modify some user properties during the process. A CSV file allows you to open the file in Excel and edit the fields as needed. You can take the output of this script and use it to create uses in a new domain with this script.
Get-Mailbox -OrganizationalUnit "User OU" | Export-Csv -f User_Mailboxes.csv
Export details for all mailboxes for user in OU.txt (76.00 bytes)
9f729d01-b120-4b35-b072-d7d8f6557208|0|.0
16. October 2011 11:23
This script creates users via Powershell. I had to create 500 users in a new Active Directory domain that I had previously exported from an old domain. This script can be run from the command line in PowerShell. I have attached a .TXT file with the script if you would like to download it.
You will need a .CSV file with the following columns:
- Alias
- UPN
- Name
- DisplayName
- FirstName
- LastName
- OU
Import-Csv 'Users.csv' | ForEach-Object { New-ADUser -SamAccountName $_.Alias -UserPrincipalName $_.UPN -Name $_.Name -DisplayName $_.displayname -GivenName $_.FirstName -Surname $_.LastName -Path $_.OU -AccountPassword (ConvertTo-SecureString "Some!Password" -AsPlainText -Force) -Enabled $true -PasswordNeverExpires $false -PassThru } > Import.log
Create users from CSV.txt (349.00 bytes)
373d458d-b1c1-44ea-b257-8e7984e0c086|0|.0
16. January 2011 17:55
A project I am working on requires me to import and overwrite everchanging data from a SQL database into a Manifold .map file. This .map file is then used to generate WMS tiles that are overlaid over Google Maps. Here is the quick and dirty script to bring in a table/view from SQL into Manifold and save the .map.
wscript.echo "Beginning Import"
set app = createobject("Manifold.Application")
set doc = app.NewDocument("C:\test_dir\map.map", false)
Set SQLImport=doc.NewDataSource()
SQLImport.ConnectionString = "DRIVER={SQL Server};SERVER=.\SQLExpress;UID=user;PWD=pass;DATABASE=database"
SQLImport.ConnectionType ="SQL Server"
TableName= "dbo.TABLE_NAME.Geometry"
SQLImport.ImportDrawing (TableName)
doc.Close(true)
set SQLImport = nothing
set doc = nothing
set app = nothing
wscript.echo "Ended Import"
2ffe32f9-3435-4689-b0a6-38927656f107|0|.0
By: Jim
Category: Mapping
Tags: manifold
12. February 2010 15:41
I have found that Google does a good job with generic data but often a company needs to display their GIS data on a Google Map. This is often the case when the general public is viewing the data and doesn't want to learn how a 'heavy' IMS website works. In this case, I often suggest a Google Map Mashup using a WMS.
The Mashup gives us a few great features:
- Ease of use
- Speed of deployment
- Capacity to scale (if using a cache of generated tiles)
You'll need a few things to get started:
- A place to host the website (this can be 'localhost' if you are developing and testing on the same machine)
- A working WMS (I assume you have one of these if you are trying to create a mashup.)
- A Google Map API key
- A Snippet of code that helps generate the request to the WMS (Found Here).
I have attached a simple example that you will need to put on your server and change the WMS layers.
WMS_Google_Mashup.txt (2.72 kb)

009f7454-bc61-432b-bd8c-9ff13bf17113|0|.0