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

Hi, I have this Script to check if a condition is met # The condition is met if $Context.ConditionIsMet is set to $True. $Context.ConditionIsMet = $False $inputString = " ... or issue with this match function using in a "if script returns true" condition?

asked Oct 31 by wintec01 (1.5k points)
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

In a business rule, I'd like to pass Adaxes variables into a powershell script that I'll run. For example, pass %username% into the script so it can be used inside the script.

asked Sep 5 by P-Sysadmin (20 points)
3,549 questions
3,240 answers
8,232 comments
547,814 users