This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

$Request Object

Hi All,

 

I have written the script below however it seems to fail upon the $request object, I don't really know much about this object and couldn't find much information. Please help!

 

function onPostCreate($Request)
{

    $Adcomputer = Get-QADComputer -Name $Request.name
    $Adcomputername = $Adcomputer | select -ExpandProperty name
    switch -Wildcard ($Adcomputername) {
    "lp-lon*" {$ou="OU=London Laptops,OU=London Computers,OU=London,OU=Organisation,DC=X,DC=COM"}
    "pc-lon*" {$ou="OU=London PC,OU=London Computers,OU=London,OU=Organisation,DC=X,DC=COM"}
    "lp-rom*" {$ou="OU=Laptops,OU=Romania Computers,OU=Romania,OU=Organisation,DC=X,DC=COM"}
    "lp-sing*" {$ou="OU=Singapore Laptops,OU=Singapore,OU=Organisation,DC=X,DC=COM"}
 }
    if ($ou -ne $null) {Move-QADObject -Identity $AdComputer.DN -NewParentContainer $ou}

}

  • $Request has three default object name properties:

    GUID
    DN
    Name

    One way you can find this is by taking a $Request object and piping it through Get-Member:

    $Request | Get-Member | out-file "Request_members.txt"

    Anyway...

    You really don't need to do the "Get" as you have obtained the computer name from the $Request.

    So, you can just have your first line as:

    $AdcomputerName = $($Request.name)

    ...and leave out the second line entirely.