Creating a scheduler for power shell command problem

Dear All


I,m  creating a scheduler for power shell command in window 8.1, but i received below XML problem, any idea  ?

this is the command
Get-ADGroupmember -identity "SG-AllUsers" | % { get-aduser $_.samaccountname -property * | select * } | export-csv C:\ATLAS.csv -notypeinformation


PS
piaakitAsked:
Who is Participating?
 
Hello ThereSystem AdministratorCommented:
It's easy.
Just create a new task that will run Powershell.exe under admin account and then in Arguments field write the path to your script.
(arguments:  -ExecutionPolicy RemoteSigned -File C:\script.ps1)

Step-by-step here.
0
 
Alex Green3rd Line Server SupportCommented:
$Groups = Get-ADGroupMember "insert group here"

$Table = @()

$Record = [ordered]@{
"Group Name" = ""
"Name" = ""
"Username" = ""
}



Foreach ($Group in $Groups)
{

$Arrayofmembers = Get-ADGroupMember -identity $Group | select name,samaccountname

foreach ($Member in $Arrayofmembers)
{
$Record."Group Name" = $Group
$Record."Name" = $Member.name
$Record."UserName" = $Member.samaccountname
$objRecord = New-Object PSObject -property $Record
$Table += $objrecord

}

}

$Table | export-csv "C:\temp\SecurityGroups.csv" -NoTypeInformation

Open in new window

0
 
Alex Green3rd Line Server SupportCommented:
Try using that script above, you should find it works a little better. I think it's the export function of everything that's causing the issue.

Thanks
Alex
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.