SlideShare a Scribd company logo
1 of 1
<#Import in modules, if statement for PSSnapin so that it doesn't throw
an error if it is already loaded.#>
Import-Module ActiveDirectory
if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.Admin -
ErrorAction SilentlyContinue) -eq $null )
{
add-pssnapin Microsoft.Exchange.Management.PowerShell.Admin
}
<#Clear variables so they are not retaining any old values#>
Get-Variable -Exclude PWD,*Preference | Remove-Variable -EA 0
<#Variables needed to complete script. Domain OU and AD Servers#>
$ausOneOffOU = "OU=One-Off user
mailbox,OU=Users,OU=Corporate,DC=austin,DC=kmvtechnologies,DC=com"
$ausDC = "SanitizedServerName.austin.kmvtechnologies.com"
$ausCred = Get-Credential -Message "This is the AUSTIN domain" -
ErrorAction Stop
<#Create an Array from Get-mailbox cmdlet that has the value
"LinkedMailbox" tying it to a Corporate account, .count value used to
check results against expected#>
$mailboxes = Get-Mailbox -resultSize unlimited -RecipientTypeDetails
usermailbox -Verbose
foreach ($mailbox in $mailboxes){
Get-ADUser $mailbox.SamAccountName -Server $ausDC -Credential
$ausCred -Verbose | Move-ADObject -TargetPath $ausOneOffOU -Server
$ausDC -Credential $ausCred -Verbose -ErrorAction Stop
}

More Related Content

Viewers also liked

Meet the Foodies..RTE Food Lifestyle
Meet the Foodies..RTE Food LifestyleMeet the Foodies..RTE Food Lifestyle
Meet the Foodies..RTE Food Lifestylegarretflower
 
Graduationpowerpoint 10
Graduationpowerpoint 10Graduationpowerpoint 10
Graduationpowerpoint 10beckdr
 
D.g..act3.lina giraldo
D.g..act3.lina giraldoD.g..act3.lina giraldo
D.g..act3.lina giraldodavidgj1981
 
Ազնվանորի
ԱզնվանորիԱզնվանորի
Ազնվանորիganyan
 
ณรงคฤทธิ์ ฮดฤาชา
ณรงคฤทธิ์ ฮดฤาชาณรงคฤทธิ์ ฮดฤาชา
ณรงคฤทธิ์ ฮดฤาชาNarongrit Hotrucha
 
Globos1
Globos1Globos1
Globos1rose
 
Metrology and quality control 5S.
Metrology and quality control 5S.Metrology and quality control 5S.
Metrology and quality control 5S.Chaitanya Dixit
 
Course feedback forms Uxbridge
Course feedback forms UxbridgeCourse feedback forms Uxbridge
Course feedback forms UxbridgeNik Johnson
 
Tutor Feedback forms DS Course 21-23 Oct 2013
Tutor Feedback forms DS Course 21-23 Oct 2013Tutor Feedback forms DS Course 21-23 Oct 2013
Tutor Feedback forms DS Course 21-23 Oct 2013Nik Johnson
 

Viewers also liked (16)

Meet the Foodies..RTE Food Lifestyle
Meet the Foodies..RTE Food LifestyleMeet the Foodies..RTE Food Lifestyle
Meet the Foodies..RTE Food Lifestyle
 
Graduationpowerpoint 10
Graduationpowerpoint 10Graduationpowerpoint 10
Graduationpowerpoint 10
 
presentacion
presentacionpresentacion
presentacion
 
D.g..act3.lina giraldo
D.g..act3.lina giraldoD.g..act3.lina giraldo
D.g..act3.lina giraldo
 
Ազնվանորի
ԱզնվանորիԱզնվանորի
Ազնվանորի
 
Hoopgirl DVD
Hoopgirl DVDHoopgirl DVD
Hoopgirl DVD
 
Bibian
BibianBibian
Bibian
 
Info sacu
Info sacuInfo sacu
Info sacu
 
Slides 7º b mar
Slides 7º b marSlides 7º b mar
Slides 7º b mar
 
ณรงคฤทธิ์ ฮดฤาชา
ณรงคฤทธิ์ ฮดฤาชาณรงคฤทธิ์ ฮดฤาชา
ณรงคฤทธิ์ ฮดฤาชา
 
Globos1
Globos1Globos1
Globos1
 
Rsm ppt
Rsm pptRsm ppt
Rsm ppt
 
Sudama Charitra 1
Sudama Charitra 1Sudama Charitra 1
Sudama Charitra 1
 
Metrology and quality control 5S.
Metrology and quality control 5S.Metrology and quality control 5S.
Metrology and quality control 5S.
 
Course feedback forms Uxbridge
Course feedback forms UxbridgeCourse feedback forms Uxbridge
Course feedback forms Uxbridge
 
Tutor Feedback forms DS Course 21-23 Oct 2013
Tutor Feedback forms DS Course 21-23 Oct 2013Tutor Feedback forms DS Course 21-23 Oct 2013
Tutor Feedback forms DS Course 21-23 Oct 2013
 

Similar to MassMigrateUsersOU

exportDisabledUsersRemoveMailbox
exportDisabledUsersRemoveMailboxexportDisabledUsersRemoveMailbox
exportDisabledUsersRemoveMailboxDaniel Gilhousen
 
Large scale machine learning projects with R Suite
Large scale machine learning projects with R SuiteLarge scale machine learning projects with R Suite
Large scale machine learning projects with R SuiteWLOG Solutions
 
Large scale machine learning projects with r suite
Large scale machine learning projects with r suiteLarge scale machine learning projects with r suite
Large scale machine learning projects with r suiteWit Jakuczun
 
Yves & Zed @ Developer Conference 2013
Yves & Zed @ Developer Conference 2013Yves & Zed @ Developer Conference 2013
Yves & Zed @ Developer Conference 2013FabianWesnerBerlin
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access RunbookTaha Shakeel
 
Ruby on Rails testing with Rspec
Ruby on Rails testing with RspecRuby on Rails testing with Rspec
Ruby on Rails testing with RspecBunlong Van
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express Jeetendra singh
 
Rally - Benchmarking_as_a_service - Openstack meetup
Rally - Benchmarking_as_a_service - Openstack meetupRally - Benchmarking_as_a_service - Openstack meetup
Rally - Benchmarking_as_a_service - Openstack meetupAnanth Padmanabhan
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauSpiffy
 
Unsupervised Aspect Based Sentiment Analysis at Scale
Unsupervised Aspect Based Sentiment Analysis at ScaleUnsupervised Aspect Based Sentiment Analysis at Scale
Unsupervised Aspect Based Sentiment Analysis at ScaleAaron (Ari) Bornstein
 
Cutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryCutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryWilliam Candillon
 
Active mq Installation and Master Slave setup
Active mq Installation and Master Slave setupActive mq Installation and Master Slave setup
Active mq Installation and Master Slave setupRamakrishna Narkedamilli
 
Automating Azure VMs with PowerShell
Automating Azure VMs with PowerShellAutomating Azure VMs with PowerShell
Automating Azure VMs with PowerShellAlexander Feschenko
 

Similar to MassMigrateUsersOU (20)

MassChangeCORPEmail
MassChangeCORPEmailMassChangeCORPEmail
MassChangeCORPEmail
 
getSIDUsers
getSIDUsersgetSIDUsers
getSIDUsers
 
exportDisabledUsersRemoveMailbox
exportDisabledUsersRemoveMailboxexportDisabledUsersRemoveMailbox
exportDisabledUsersRemoveMailbox
 
termUserGroups
termUserGroupstermUserGroups
termUserGroups
 
Large scale machine learning projects with R Suite
Large scale machine learning projects with R SuiteLarge scale machine learning projects with R Suite
Large scale machine learning projects with R Suite
 
Large scale machine learning projects with r suite
Large scale machine learning projects with r suiteLarge scale machine learning projects with r suite
Large scale machine learning projects with r suite
 
Rest with-spray
Rest with-sprayRest with-spray
Rest with-spray
 
Deploying SharePoint @ Cloud
Deploying SharePoint @ CloudDeploying SharePoint @ Cloud
Deploying SharePoint @ Cloud
 
Yves & Zed @ Developer Conference 2013
Yves & Zed @ Developer Conference 2013Yves & Zed @ Developer Conference 2013
Yves & Zed @ Developer Conference 2013
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access Runbook
 
Ruby on Rails testing with Rspec
Ruby on Rails testing with RspecRuby on Rails testing with Rspec
Ruby on Rails testing with Rspec
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
 
Rally - Benchmarking_as_a_service - Openstack meetup
Rally - Benchmarking_as_a_service - Openstack meetupRally - Benchmarking_as_a_service - Openstack meetup
Rally - Benchmarking_as_a_service - Openstack meetup
 
Celery with python
Celery with pythonCelery with python
Celery with python
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 
Unsupervised Aspect Based Sentiment Analysis at Scale
Unsupervised Aspect Based Sentiment Analysis at ScaleUnsupervised Aspect Based Sentiment Analysis at Scale
Unsupervised Aspect Based Sentiment Analysis at Scale
 
Cutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryCutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQuery
 
Active mq Installation and Master Slave setup
Active mq Installation and Master Slave setupActive mq Installation and Master Slave setup
Active mq Installation and Master Slave setup
 
Automating Azure VMs with PowerShell
Automating Azure VMs with PowerShellAutomating Azure VMs with PowerShell
Automating Azure VMs with PowerShell
 

MassMigrateUsersOU

  • 1. <#Import in modules, if statement for PSSnapin so that it doesn't throw an error if it is already loaded.#> Import-Module ActiveDirectory if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.Admin - ErrorAction SilentlyContinue) -eq $null ) { add-pssnapin Microsoft.Exchange.Management.PowerShell.Admin } <#Clear variables so they are not retaining any old values#> Get-Variable -Exclude PWD,*Preference | Remove-Variable -EA 0 <#Variables needed to complete script. Domain OU and AD Servers#> $ausOneOffOU = "OU=One-Off user mailbox,OU=Users,OU=Corporate,DC=austin,DC=kmvtechnologies,DC=com" $ausDC = "SanitizedServerName.austin.kmvtechnologies.com" $ausCred = Get-Credential -Message "This is the AUSTIN domain" - ErrorAction Stop <#Create an Array from Get-mailbox cmdlet that has the value "LinkedMailbox" tying it to a Corporate account, .count value used to check results against expected#> $mailboxes = Get-Mailbox -resultSize unlimited -RecipientTypeDetails usermailbox -Verbose foreach ($mailbox in $mailboxes){ Get-ADUser $mailbox.SamAccountName -Server $ausDC -Credential $ausCred -Verbose | Move-ADObject -TargetPath $ausOneOffOU -Server $ausDC -Credential $ausCred -Verbose -ErrorAction Stop }