-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial upload of scripts available on the blog.
- Loading branch information
unknown
authored and
unknown
committed
Mar 17, 2016
1 parent
242b76c
commit f8e03bb
Showing
3 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
@ECHO OFF | ||
|
||
REM Location of the ntfrsutil tool from the File Replication Service Diagnostics Tool. | ||
REM This can be downloaded from: http://www.microsoft.com/en-gb/download/details.aspx?id=8613 | ||
SET NTFRSUTL="C:\Program Files (x86)\Windows Resource Kits\Tools\FRSDiag\ntfrsutl.exe" | ||
|
||
CALL :ForceKCCUpdate | ||
|
||
REM Get the forest partition dn without specifying the parent domain. | ||
FOR /F %%p IN ('dsquery * forestroot -scope subtree -filter "(objectClass=crossRefContainer)" -l -limit 0') DO ( | ||
|
||
REM Get all parent/child domains from the forest configuration. | ||
FOR /F %%d IN ('dsquery * %%p -scope subtree -filter "(&(objectClass=crossRef)(nETBIOSName=*))" -attr dnsRoot -l -limit 0') DO ( | ||
CALL :ReplicateDomain %%d | ||
) | ||
) | ||
|
||
GOTO END | ||
|
||
:ReplicateDomain | ||
ECHO Replicating Domain: %1 | ||
|
||
REM Replicate SYSVOL. | ||
FOR /F %%f IN ('DsQuery Server -domain %1 -limit 0 -o rdn') DO ( | ||
FOR /F %%t IN ('DsQuery Server -domain %1 -limit 0 -o rdn') DO ( | ||
IF /I "%%f" NEQ "%%t" ( | ||
ECHO Replicating SYSVOL from %%f to %%t | ||
%NTFRSUTL% forcerepl %%t /r "Domain System Volume (SYSVOL share)" /p %%f | ||
) | ||
) | ||
) | ||
|
||
REM Replicate AD. | ||
ECHO Replicating AD | ||
repadmin /syncall %1 /APed | ||
|
||
GOTO END | ||
|
||
:ForceKCCUpdate | ||
ECHO Forcing KCC Update | ||
|
||
REM Force the KCC to recalculate in all sites. | ||
FOR /F %%s IN ('DsQuery Site -limit 0 -o rdn') DO ( | ||
repadmin /kcc site:%%s | ||
) | ||
|
||
GOTO END | ||
|
||
:END |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Refresh all VM's | ||
|
||
param ( | ||
[string]$server = $(Throw "parameter 'server' is required!"), | ||
[string]$username, | ||
[string]$password | ||
) | ||
|
||
# Connect to the specified server | ||
If ($username -eq "") { | ||
# Connect to server without username & password | ||
Connect-VIServer -Server $server | ||
} | ||
ElseIf ($username -ne "" -and $password -eq "") { | ||
# Connect to server with username only | ||
Connect-VIServer -Server $server -User $username | ||
} | ||
Else{ | ||
# Connect to server with username & password | ||
Connect-VIServer -Server $server -User $username -Password $password | ||
} | ||
|
||
# Get all VM's, excluding templates | ||
$vms = Get-View -ViewType VirtualMachine -Property Name -Filter @{"Config.Template"="false"} | ||
foreach($vm in $vms){ | ||
$vm.reload() | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<# | ||
This script sets a users account so that the password is to expire as per MRG policy, | ||
and resets the last password change date so that the user doesn't need login and change | ||
their password straight away. | ||
#> | ||
|
||
# Define input parameters the script can accept. | ||
param | ||
( | ||
[Parameter(Mandatory=$True)] | ||
[string]$SearchBase, | ||
|
||
[Parameter(Mandatory=$True)] | ||
[string]$DNSDomainName, | ||
|
||
[Parameter(Mandatory=$True)] | ||
[string]$sAMAccountName, | ||
|
||
[bool]$Change = $False, | ||
|
||
[string]$LogFile = $MyInvocation.MyCommand.Name + ".log" | ||
) | ||
|
||
$Culture = Get-Culture | ||
If ((Test-Path $Logfile) -eq $False) | ||
{ | ||
# Add headers to the LogFile if it doesn't already exist. | ||
Add-Content $LogFile "sAMAccountName, LastChange, Today, Changed" | ||
} | ||
|
||
# Get the user & properties from AD | ||
$ADUser = Get-ADUser -Filter {sAMAccountName -eq $sAMAccountName} -SearchScope Subtree -SearchBase $SearchBase -Properties Name,pwdLastSet,PasswordNeverExpires -Server $DNSDomainName | ||
|
||
# Check that user exist before going further. | ||
If($ADUser -eq $Null) | ||
{ | ||
Write-Host "User not found. Aborting." | ||
} | ||
Else | ||
{ | ||
# Get the sAMAccountName from AD (Don't rely on the users input) | ||
$ADsAMAccountName = $ADUser.sAMAccountName | ||
|
||
# Get todays date and format it correctly. | ||
$Today = Get-Date -Format ($Culture.DateTimeFormat.FullDateTimePattern) | ||
|
||
# Get the date of the last password change and format it correctly. | ||
$LastChange = Get-Date -Date ([DateTime]::FromFileTime($ADUser.pwdLastSet)) -Format ($Culture.DateTimeFormat.FullDateTimePattern) | ||
|
||
If ($Change -eq $True) | ||
{ | ||
# Set the password to expired, must be done first. | ||
$ADUser.pwdLastSet = 0 | ||
# Set the account so that the password expires. | ||
$ADUser.PasswordNeverExpires = $False | ||
# Save the changes | ||
Set-ADUser -Instance $ADUser -Server $DNSDomainName | ||
|
||
# Reset the date of the last password change to today. | ||
$ADUser.pwdLastSet = -1 | ||
# Save the changes | ||
Set-ADUser -Instance $ADUser -Server $DNSDomainName | ||
|
||
# Inform the user of the script that the account was changed. | ||
Write-Host "Account Changed." | ||
} | ||
|
||
# Log the change to the LogFile. | ||
Add-Content $LogFile "$ADsAMAccountName, $LastChange, $Today, $Change" | ||
} |