Repository of custom PowerShell scripts useful for managing MTD servers.
Most of these scripts will use PowerShell Remoting. You should enable it on any remote servers you plan on interacting with by running the following command at an administrative PowerShell Command Prompt.
Scripts that interact with Office 365 must be run in Microsoft Exchange Online PowerShell Module.
Enable-PSRemoting –forceThese scripts will require you to enable unsigned script execution. You can do so by running the following command at an administrative PowerShell Command Prompt.
Set-ExecutionPolicy Unrestricted -ForceRun Install.ps1 or follow the instructions bellow to install manually.
- Create a directory called
C:\Users\%username%\Documents\WindowsPowerShell\Modules - Open PowerShell and make sure the directory is in your path (
$env:PSModulePath). - Close Powershel and copy the
MtdModulesdirectory into ``. - Reopen PowerShell and verify that the modules are properly installed by typing running the command
Get-Command -Module MtdModules - To use the modules run the command
Import-Module MtdModules.
Kills all PSSessions for a remote computer
The remote server must have PowerShell Remoting enabled.
Remove-MtdRemoteConnections -computerName <COMPUTER_NAME>Recycles the app pool on a remote IIS server
The remote server must have the Web Server Administration Cmdlets installed.
The remote server must have PowerShell Remoting enabled.
Restart-MtdAppPool -computerName <COMPUTER_NAME> -appPoolName <APP_POOL_NAME>Enable litigation hold for a single user or for all users.
Microsoft Exchange Online PowerShell Module
For a single user
Enable-LitigationHold -user foo@cumtd.com -username foo@cumtd.comFor all users
Enable-LitigationHold -credential -username foo@cumtd.comPulls a list of all users on a shared calendar, removes them, then re-addes them.
This is a fix that Microsoft Support recomends when calendar appointments cannot be seen between users.
Microsoft Exchange Online PowerShell Module
Redo-SharedCalendarPermission -mailbox largeconference@cumtd.com -username foo@cumtd.comHides a mailbox from the Exchange GAL.
The remote server must have PowerShell Remoting enabled.
Hide-MailboxFromGAL -mailboxIdentity jdoe -dc dc1.example.comMove a users home directory to a new location. In addition to moving the directory. Permissions will be set on the directory, the share will be moved, and the users home directory in AD will be updated.
The remote servers must have PowerShell Remoting enabled.
Move-HomeDirectories -originBaseDirectory d:\users -destinationBaseDirectory e:\active -dc mtddc1.cumtd.com -fs mtdfs1.cumtd.com -authUserName cumtd.com\foo -usersToMove user1, user2, user3