Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Quest AD Cmdlet as part of a script

Reply
 
Old 02-20-2009   #1 (permalink)
Jobbsy


 
 

Quest AD Cmdlet as part of a script

I've tried the QuestADCmdlet in script below and got to grips running them
from the PS CMD line, however, when included as part of a script - see as
follows - the cmdlet doesn't seem to run (the csv files named by groupname
are crtaed fine - they are just not populated with anything - Any help would
be greatly appreciated:

$Membersfile = 'D:\Groups\members.csv'

#import the input file of groups
$IGroups = Import-Csv 'D:\Groups\groups.csv'

$OriginalGroup = $IGroup

Foreach($IGroup in $IGroups) {

$G = $IGroup.group

$Membersfile = 'D:\Groups\'+$G+'.csv'

function get-members{
param($G)

$members = Get-QADGroupMember -Identity $G -indirect
$strOutputString = "$members"
$strOutputString | out-file -filepath $Membersfile -encoding ascii -append

}

get-members
}

--
jobbsy@xxxxxx

My System SpecsSystem Spec
Old 02-20-2009   #2 (permalink)
Brandon Shell [MVP]


 
 

Re: Quest AD Cmdlet as part of a script

In the script try adding the snapin

add-pssnapin Quest.ActiveRoles.ADManagement -ea 0

Brandon Shell [MVP]
------------------------
Blog: http://www.bsonposh.com/
Author: http://www.TurboChargeAD.org
Profile: https://mvp.support.microsoft.com/profile/Brandon

J> I've tried the QuestADCmdlet in script below and got to grips running
J> them from the PS CMD line, however, when included as part of a script
J> - see as follows - the cmdlet doesn't seem to run (the csv files
J> named by groupname are crtaed fine - they are just not populated with
J> anything - Any help would be greatly appreciated:
J>
J> $Membersfile = 'D:\Groups\members.csv'
J>
J> #import the input file of groups
J> $IGroups = Import-Csv 'D:\Groups\groups.csv'
J> $OriginalGroup = $IGroup
J>
J> Foreach($IGroup in $IGroups) {
J>
J> $G = $IGroup.group
J>
J> $Membersfile = 'D:\Groups\'+$G+'.csv'
J>
J> function get-members{
J> param($G)
J> $members = Get-QADGroupMember -Identity $G -indirect
J> $strOutputString = "$members"
J> $strOutputString | out-file -filepath $Membersfile -encoding ascii
J> -append
J> }
J>
J> get-members
J> }


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Quest AD cmdlet -what is the cmdlet to remove computer object PowerShell
quest cmdlet : get-qadcomputer PowerShell
Registering a Script CmdLet? PowerShell
Script Cmdlet Bug? PowerShell
Re: Using a colon in a script to call another cmdlet PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46