This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
This is a PowerShell function wrapping the ADMT executable to abstract out migrating Active Directory users. | |
Read all the ADMT docs, and all the code and comments below before considering using this : ) | |
The COM object was covered nicely by Jan Egil Ring: | |
http://blog.powershell.no/2010/08/04/automate-active-directory-migration-tool-using-windows-powershell/ | |
Unfortunately, the COM object does not support Include files, a critical requirement for us. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$StaleGroupsobj = @() | |
$DC = (Get-ADDomain).DNSroot | |
$Groups = (Get-ADGroup -Filter * -Server $DC).name | |
Foreach ($Group in $Groups){ | |
$Group = Get-ADGroup -Filter {Name -eq $Group} -Properties Name, DistinguishedName, ` | |
GroupCategory, GroupScope, whenCreated, whenChanged, member, ` | |
memberOf, sIDHistory, SamAccountName, Description -Server $DC | | |
Select-Object Name, DistinguishedName, GroupCategory, GroupScope, ` | |
whenCreated, whenChanged, member, memberOf, SID, SamAccountName, ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$StaleGroupsobj | where MemberCount -eq '0'` | |
| select Name,MemberCount,MemberofCount,DaysSinceChange` | |
| where MemberOfCount -eq '0' | where DaysSinceChange -GE '190'| ft |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configuration HTTPPullServer | |
{ | |
# Modules must exist on target pull server | |
Import-DSCResource -ModuleName xPSDesiredStateConfiguration | |
Node WS2016P3 | |
{ | |
WindowsFeature DSCServiceFeature | |
{ | |
Ensure = "Present" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[DSCLocalConfigurationManager()] | |
Configuration LCM_HTTPPULL | |
{ | |
param | |
( | |
[Parameter(Mandatory=$true)] | |
[string[]]$ComputerName, | |
[Parameter(Mandatory=$true)] | |
[string]$guid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configuration SMTP { | |
Node HTTPComputers { | |
WindowsFeature SMTP{ | |
Name = 'SMTP-Server' | |
Ensure = 'Present' | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Copy-SQLTable { | |
<# | |
.SYNOPSIS | |
Copies a table from a source database and inserts it into the target database. | |
.DESCRIPTION | |
Takes all the data from the source database and inserts it into the target database with the same name. | |
.PARAMETER TableName | |
Specifies the table name to be copied from the source and inserted into the target. | |
.PARAMETER SourceServer | |
Specifies source server DNS name and instance, use ServerName\InstanceName. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Disable-ADComputer { | |
<# | |
.SYNOPSIS | |
Disables Computers and moves them to the specified OU. | |
.DESCRIPTION | |
Take string or object input for computers then disables each one and moves to the specified ou | |
then outputs errors to a log file. | |
.PARAMETER Identity | |
Name of computer or computers | |
.PARAMETER DisabledOU |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$parms = @{ | |
'class'='Win32_LogicalDisk'; | |
'computername'='DESKTOP'; | |
'filter'='drivetype=3'; | |
} | |
Get-WmiObject @parms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Move-ADGroupMemberofToMember { | |
<# | |
.SYNOPSIS | |
Moves all Member Of Groups to the Members section of an Active Directory group. | |
.DESCRIPTION | |
Queries an Active Directory group for all Member Of groups then add them to the members section | |
and removes them from the member of section of the active directory group. | |
.PARAMETER Identity | |
Specify the group to run the cmdlet against. | |
.EXAMPLE |
OlderNewer