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

For instance to execute a powershell script that enable MFA for all member in that group?

asked Jan 27, 2023 by samuel.anim-addo (20 points)
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, 2022 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, 2022 by jbahou (20 points)
0 votes
1 answer

Hi All, I am currently using the 30 day free trial of Adaxes and seeing if we can use it to achieve our method of user provisioning. I am looking into server-side ... variable value within an SQL query Can this be achieved? Any help is much appreciated, Thanks

asked Feb 1 by Lewis (40 points)
3,326 questions
3,026 answers
7,727 comments
544,678 users