A small collection specialised scripts for Active Directory.
Includes:
- Compare-ADMemberOf
- Get-ADSystemInfo
- Get-GroupMemberTree
- Get-LdapObject
- Get-MemberOfTree
- Test-LdapSslConnection
function Measure-ChildItem { | |
<# | |
.SYNOPSIS | |
Recursively measures the size of a directory. | |
.DESCRIPTION | |
Recursively measures the size of a directory. | |
Measure-ChildItem uses win32 functions, returning a minimal amount of information to gain speed. Once started, the operation cannot be interrupted by using Control and C. The more items present in a directory structure the longer this command will take. | |
This command supports paths longer than 260 characters. |
using namespace System.Management.Automation.Language | |
function Enable-ScriptAlias { | |
<# | |
.SYNOPSIS | |
Replace all aliased commands in a script with the alias name. | |
.DESCRIPTION | |
Replace all aliased commands in a script with the alias name. |
A small collection specialised scripts for Active Directory.
Includes:
using module ActiveDirectory | |
using namespace System.Reflection | |
function Convert-ADFilter { | |
<# | |
.SYNOPSIS | |
Converts PowerShell-style filters used by the AD module into LDAP filters. | |
.DESCRIPTION | |
Convert-ADFilter uses the QueryParser from the AD module to convert PowerShell-style filters into LDAP |
using assembly System.DirectoryServices.Protocols | |
using namespace System.DirectoryServices.Protocols; using namespace System.Collections.Generic | |
function Get-LdapObject { | |
<# | |
.SYNOPSIS | |
Get objects from an LDAP directory. | |
.DESCRIPTION | |
Get objects from an LDAP directory. | |
.EXAMPLE |
using namespace System.Collections.Generic; using namespace System.Text | |
Add-Type -TypeDefinition ' | |
using System; | |
using System.Runtime.InteropServices; | |
using System.Text; | |
public class WindowTools | |
{ | |
public delegate bool EnumWindowsProc(IntPtr hWnd, int lParam); |
function ConvertTo-TableFormat { | |
<# | |
.SYNOPSIS | |
Rebuild an object based on the Format Data for the object. | |
.DESCRIPTION | |
Allows an object to be rebuilt based on the view data for the object. Uses Select-Object to create a new PSCustomObject. | |
#> | |
[CmdletBinding()] | |
param ( |
Add-Type -TypeDefinition @' | |
using System.Runtime.InteropServices; | |
using System.Text; | |
public class Native | |
{ | |
[DllImport("kernel32.dll", SetLastError = true)] | |
public static extern uint QueryDosDevice( | |
string lpDeviceName, | |
StringBuilder lpTargetPath, |
using namespace System.Management.Automation | |
using namespace System.Management.Automation.Language | |
using namespace System.Reflection | |
function Get-FunctionInfo { | |
<# | |
.SYNOPSIS | |
Get an instance of FunctionInfo. | |
.DESCRIPTION | |
FunctionInfo does not present a public constructor. This function calls an internal / private constructor on FunctionInfo to create a description of a function from a script block or file containing one or more functions. |
function Update-RegistryFile { | |
<# | |
.SYNOPSIS | |
Updates a registry file. | |
.DESCRIPTION | |
Line break and certain characters will not import from standard registry files (even if export works). | |
This function replaces any entry with line breaks with a hex value representing the string. | |
#> |