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
Get-QADUser -Disabled ` | |
| Select Name, DisplayName, Department, WhenChanged ` | |
| Sort DisplayName ` | |
| Format-Table |
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
# Load the Exchange management cmdlets. | |
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin | |
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Support | |
# Import all the modules located in: | |
# %windir%\System32\WindowsPowerShell\v1.0\Modules | |
ImportSystemModules | |
$usersFromFile = Get-Content "users.txt" |
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
# Load a handy Quest snap-in for Active Directory cmdlets | |
Add-PSSnapin Quest.ActiveRoles.ADManagement | |
Get-QADUser tommy.test | Select -ExpandProperty memberof | ` | |
ForEach-Object { ($_.split(','))[0].replace('CN=','') } | ` | |
Sort $_ | ` | |
Out-GridView |
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
# | |
# Get the group members for each group from an array, and export the member list | |
# to a .csv file. Then open all the .csv files in Excel. | |
# | |
Clear-Host | |
$outputFolder = "c:\tempo" | |
$groupList = @("Group1", | |
"Group2", |
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
# | |
# %userprofile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 | |
# | |
# | |
# Load some snap-ins | |
# | |
Add-PSSnapin Quest.ActiveRoles.ADManagement | |
# |
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
# | |
# Copy all files matching a pattern from one folder to another. A counter is pre-pended to | |
# ensure unique destination file names. | |
# | |
Clear-Host | |
$sourceFolderFullPath = "C:\SOURCE_PATH" | |
$destinationFolderFullPath = "C:\DESTINATION_PATH" | |
$filter = "FILTER*.TXT" | |
$count = 1 |
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
# Depends on the Quest snap-in for Active Directory management | |
Add-PSSnapin Quest.ActiveRoles.ADManagement | |
Get-QADUser -Disabled -ShowProgress -PageSize 1000 -SizeLimit 0 | ` | |
Where { $_.WhenChanged -gt (Get-Date).AddDays(-10) } | ` | |
Select DisplayName, Name, Department, Title, WhenChanged | ` | |
Sort DisplayName | ` | |
Format-Table |
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
# Flatten a folder tree by moving contents of the source path | |
# recursively to the destination path. | |
# | |
# If there is a collision in the destination due to two files | |
# having the same name, then a timestamp is appended to the | |
# base name of the file being moved to create a new unique name. | |
Clear-Host | |
$sourceFolderFullPath = "c:\source" |
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
Function EmailScriptReport | |
{ | |
# Sends an email using the specified to/from, subject, body, and | |
# and SMTP server. Allows an attachment to be included. Also includes | |
# in the body the source path of the running script to improve | |
# traceability. | |
Param ( | |
[string]$To, | |
[string]$From, |
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
Function GetStoredProcedureResult | |
{ | |
# Gets an array of objects representing the return value of the | |
# specified stored procedure. This function allows up to one | |
# (optional) named SQL integer parameter to be provided. | |
Param ( | |
[string]$Server = $(Throw "No SQL server specified."), | |
[string]$Database = $(Throw "No database name specified."), | |
[string]$StoredProcedure = $(Throw "No stored procedure name specified."), |
OlderNewer