0 votes

I have several windows powershell scripts that work perfectly with AD- however, I can not get these to run as an Adaxes script (Scheduled Task)

It is very simple, as I include below. Any help would be most appreciated, as I will not always be available to run these reports monthly.

$dist = ForEach ($group in (Get-DistributionGroup -Filter {name -like "*project distribution list"})) 
       {  Get-DistributionGroupMember $group | Select @{Label="Group";Expression={$Group.Name}},@{Label="User";Expression={$_.Name}},PrimarySMTPAddress 
       }
    $dist | Sort Group,User | Export-CSV PDL-Members1.csv -NoTypeInformation
# Rename-Item -Path PDL-Members.csv -NewName PDL-Members_Con1_$(Get-Date -f yyyy_MM_dd).csv
by (70 points)
0

Hello,

Can you post the error messages and/or warnings that you get? Also, is it the complete script or only a part of it?

0

Hi support,

This is the complete script from adaxes, have tried to break it down to a single group name to extract members details - so there are commented sections included as well. The activity history show blank ...

Thanks

Alex

$filePath = 'd:\adaxes\pdl-mbrs.csv'

Import-Module Adaxes

$identity =  Get-AdmGroup "983pdl" # sAMAccountName
$members = Get-AdmGroupMember -Identity $identity -AdaxesService localhost

foreach ($member in $members)
{
 $dist = $member.Name
}

$dist | Export-CSV $filepath -NoTypeInformation

# $members | Export-CSV d:\adaxes\imbrs.csv -NoTypeInformation
<#
( $members = Get-AdmGroupMember -Identity $identity ) # -AdaxesService localhost )

$dist = foreach ($member in $members)
{
  #  Write-Host $member.Name
}

$dist | Sort Group,User | Export-CSV $filepath -NoTypeInformation

#>

<#

Import-Module Adaxes

$identity = "SalesGroup" # sAMAccountName
# $identity = "CN=SalesGroup,CN=Users,DC=domain,DC=com" # DN
# $identity = "{EB5FEB21-E648-42AD-B86C-89D3C6807953}" # GUID
# $identity = "S-1-5-21-573937-2149998-410785" # SID

$members = Get-AdmGroupMember -Identity $identity -Server "domain.com" `
    -AdaxesService localhost

foreach ($member in $members)
{
    Write-Host $member.Name
}

#>
#Import-Module Adaxes
#$filePath = 'd:\adaxes\test.csv'

#$groups = (Get-AdmGroup -Filter {name -like "*Project Distribution List"} | Select-Object -Property DistinguishedName)

#$Grp = Get-ADGroupMember -Identity $groups | Where {$_.ObjectClass -eq 'user'} |Get-ADUser -Properties Title,Department|Select Name,Title,Department,SamAccountName,DistinguishedName

#$Grp | Export-CSV -Path d:\adaxes\test1.csv -NoTypeInformation

# ForEach ($grp in $groups)
#       {  
#        $dist = (Get-AdmGroupMember $grp | Select-Object -Property Name)
#dist$ = Get-ADGroupMember -Identity "CN=970 - Hazelhurst Court - Project Distribution List,OU=Distribution Lists PF,OU=IT,OU=Holdings,DC=Rydon,DC=Group" -Recursive 
#       Get-DistributionGroupMember $group | Select @{Label="Group";Expression={$Group.Name}},@{Label="User";Expression={$_.Name}},PrimarySMTPAddress 
#       }
# DistinguishedName 

#$groups | Export-CSV d:\adaxes\groups.csv -NoTypeInformation

#$grp | Export-CSV d:\adaxes\grp.csv -NoTypeInformation

Please log in or register to answer this question.

Related questions

0 votes
1 answer

When running a PowerShell script as an action in a custom command, you can set the script to run as a different account and then use the RunAs property in the ... Is there another way to get the Adaxes service account's credentials from within the script?

asked Mar 31 by KelseaIT (320 points)
0 votes
1 answer

I am having an issue running a powershell script through Adaxes. I am trying to have this run as a business rule when ... $optoffice.DisabledServicePlans = "ONEDRIVESTANDARD" Set-MsolUserLicense -UserPrincipalName %userPrincipalName% -LicenseOptions $optOffice

asked Mar 2, 2015 by malsobrook (50 points)
0 votes
1 answer

Receive "Index operation failed; the array index evaluated to null. Stack trace: at &lt;ScriptBlock&gt;, &lt;No file&gt;: line 104&gt;" and "Index operation failed; the ... $GroupName, $GroupDN." } } #foreach write-output "" Write-Output "" Stop-Transcript

asked Apr 14 by jbahou (20 points)
0 votes
1 answer

Let's say I have a Business Rule that is fired prior to adding members to a group. Is it possible to get the number of objects being added to that group as ... that tells me that 6 objects will be added or is each added user treated completely independently?

asked Apr 20 by ngb (90 points)
0 votes
1 answer

Is there a way to have a Scheduled Task with 4 different condition? I want to create a scheduled task start every Monday and the condition see: The next Saturday of the week ... of the week is the fifth of the month then no action Thanks in advance, Simone

asked Jan 18 by Simone.Vailati (270 points)
2,779 questions
2,512 answers
6,574 comments
26,506 users