Invoke-AD Cmdlet
Searches and updates Microsoft Active Directory data.
Syntax
Invoke-AD [parameters]
Remarks
The Invoke-AD cmdlet allows you to use SQL statements to execute any SQL statement directly. Below is the syntax for a parameterized query:
$query = Invoke-AD -Connection $connection -Query 'SELECT * FROM User WHERE CN=@CN' -Params @{'@CN'='Administrator'}This cmdlet is also useful for executing stored procedures. Use the EXEC keyword to call a stored procedure:
$query = Invoke-AD -Connection $connection -Query 'EXEC ChangePassword NewPassword = @NewPassword' -Params @{"myNewPassword"}To pass multiple Params parameters, use a semicolon (;) as a delimiter. The code below outlines the structure of an EXEC command with two parameters (param1 and param2):
$query = Invoke-AD -Connection $connection -Query 'EXEC MyStoredProc Input1=@param1, Input2=@param2' -Params @{'@param1' = 'value1'; '@param2' = 'value2'}