locked
Using PowerShell to Move a Group of Computers RRS feed

  • Question

  • Hi All,

    I am new to PowerShell and have been asked to move a group of computers (that haven't been used in a while) to a different OU, and was hoping for some direction. My first thought was to export to a csv file, and then import by computer name. Here's my first command:

    get-qadcomputer -InactiveFor 365 | export-csv Test.csv

    How can I read-in that list of computer names and move these into a different OU? Any feedback/help would be greatly appreciated!

    Wednesday, June 19, 2013 2:03 AM

Answers

  • -SizeLimit 500 will only return 500 results. -SizeLimit 0 returns all results.

    I think you're referring to -PageSize rather than -SizeLimit.

    Bill

    • Proposed as answer by jrv Wednesday, June 19, 2013 5:26 PM
    • Marked as answer by IamMred Thursday, July 11, 2013 4:05 AM
    Wednesday, June 19, 2013 5:17 PM

All replies

  • Just move them:

    Get-QADComputer -inactive 365 | Move-QADObject  -NewParentContainerName  'ou-blah blah,...'

    That's all.


    ¯\_(ツ)_/¯

    • Proposed as answer by jrv Wednesday, June 19, 2013 2:17 AM
    Wednesday, June 19, 2013 2:17 AM
  • Thank you for the feedback. I was attempting to test with a single computer before I run the script and am receiving an error. First is the command, next the error:

    get-QADComputer ComputerName | Move-QADObject -NewParentContainerName 'ou......."

    Error:

    Move-QADObject : A parameter cannot be found that matches parameter name "NewParentContainerName"

    Should this be the name of the OU? Do I need to import something?

    Wednesday, June 19, 2013 2:47 AM
  • Thank you for the feedback. I was attempting to test with a single computer before I run the script and am receiving an error. First is the command, next the error:

    get-QADComputer ComputerName | Move-QADObject -NewParentContainerName 'ou......."

    Error:

    Move-QADObject : A parameter cannot be found that matches parameter name "NewParentContainerName"

    Should this be the name of the OU? Do I need to import something?


    You have an old version of Quest and need to upgrade.

    ¯\_(ツ)_/¯

    Wednesday, June 19, 2013 8:25 AM
  • When I run the following it does nothing, with no errors. Should I create a loop somehow to accomplish this? Thanks again, much appreciated!

    PS C:\scripts> Get-QADComputer -Inactive 365 | Move-QADObject -NewParentContainer "ou=computers,ou=Disabled Accounts,dc=x,dc=y"

    Wednesday, June 19, 2013 3:53 PM
  • Hi,

    Does the command:


    Get-QADComputer -Inactive 365

    return any results?

    Bill

    Wednesday, June 19, 2013 4:31 PM
  • Hi Bill,

    That above command displays nothing - including errors. However, substituting "-InactiveFor" for "-Inactive" does display results.

    Wednesday, June 19, 2013 4:48 PM
  • Then the next command in the pipeline will never execute. You are writing:


    Get-QADComputer -Inactive 365 | Move-QADObject ...

    Get-QADComputer produces no output, so there is nothing for Move-QADObject to do.

    Bill

    Wednesday, June 19, 2013 4:54 PM
  • Thanks for the help, much appreciated. I was able to move the first 1000 with the following command:

    Get-QADComputer -InactiveFor 365 | Move-QADObject - NewParentContainer "ou=......."

    Just need to figure out how to increase the size limit to retrieve more results... :)

    Thanks!

    Wednesday, June 19, 2013 5:07 PM
  • When in doubt learn to use HELP.  It will usually solve your issue in a couple of minutes.

    I apologize for being lazy when I types -inactive and quit before finishing with eh "For".  I am surprised it shows no error with a hanging 365.


    ¯\_(ツ)_/¯

    Wednesday, June 19, 2013 5:11 PM
  • Use


    Get-QADComputer -InactiveFor 365 -SizeLimit 0 | ...

    It helps to read the help for the commands you're using:


    help Get-QADComputer -full

    Bill

    Wednesday, June 19, 2013 5:14 PM
  • -SizeLimit 500 will only return 500 results. -SizeLimit 0 returns all results.

    I think you're referring to -PageSize rather than -SizeLimit.

    Bill

    • Proposed as answer by jrv Wednesday, June 19, 2013 5:26 PM
    • Marked as answer by IamMred Thursday, July 11, 2013 4:05 AM
    Wednesday, June 19, 2013 5:17 PM
  • -SizeLimit 500 will only return 500 results. -SizeLimit 0 returns all results.

    I think you're referring to -PageSize rather than -SizeLimit.

    Bill


    That right. My mistake.

    ¯\_(ツ)_/¯

    Wednesday, June 19, 2013 5:26 PM
  • Thanks guys! That's exactly what I needed!!
    Wednesday, June 19, 2013 5:26 PM
  • So now after attempting to move some computers (roughly 2,500), I am receiving this error. It seems to happen right around 1,500 or so. May sound like a real dumb question, but what does this mean? First is the command I'm attempting execute, next the error:

    PS C:\scripts> Get-QADComputer -InactiveFor 365 -SizeLimit 0 | Move-QADObject -NewParentContainer "ou=computers,ou=Disabled Accounts,dc=x,dc=y"

    Move-QADObject : There is a naming violation.
    At line:1 char:63
    + Get-QADComputer -InactiveFor 365 -SizeLimit 0 | Move-QADObject <<<<  -NewParentContainer "ou=computers,ou=Disabled Accounts,dc=x,dc=y"
        + CategoryInfo          : NotSpecified: (:) [Move-QADObject], COMException
        + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Quest.ActiveRoles.ArsPowerShellSnapIn.Commands.MoveObjectCmdlet

    Wednesday, June 19, 2013 9:37 PM
  • Hi,

    This is a question that you need to ask Quest Software. It is not a scripting question.

    Bill

    Wednesday, June 19, 2013 9:49 PM
  • Are you sure you have the latest version of ActiveRoles?

    &#175;\_(ツ)_/&#175;

    Wednesday, June 19, 2013 9:56 PM