Hello,
I’m apologizing in advanced if I provided too much information.
There have been times where I’ll create a script and assign variables to cmdlets . Within some of my scripts I have used the variable to access properties that I select in a custom table.Most of the time I can access the variable through dot notation and the results of the cmdlets will get exported to an excel file with the custom headers.
For some reason it’s not producing the results that I’m looking for .(In my script that I created ,I’m getting the groups listed in the main AD group (Get-ADGroupmember -identity $item.Group) and I’m getting the groups that are listed in what is called a Centrify zone by means of a powershell cmdlet (Get-CdmGroupProfile -Zone $item.DistinguishedName).
At the end I’m trying to export it to an excel spreadsheet with the Groups from the AD group as a header (AD Linux Group) and also display the groups that show up in Centrify and display them in a header in Excel (Centrify Group).
However it seems to be constantly looping through the groups and never stops or takes a really long time.
I have played around with the following and got it to work somewhat ,where it would pass the results on ,but it still isn’t working like I was expecting. I would like for it to display the results for both cmdlets (Get-ADgroupmember and Get-cdmgroupprofile) in separate columns . This is for being able to compare the differences ,but for now I would like the groups to display.
Get-CdmGroupProfile -Zone $item.DistinguishedName |%{
Get-ADGroupmember -identity $item.Group |
For example - The script below works fine.I used the script below for the one that I’m having issues with.
I assign the cmdlets to variables and then at the end I select them with the custom table by using what I think is actually dot notation to access the specific properties($zone.UserEnabled,$zonezpa.UserSource,etc) and displaying them in an easy to understand column.
$list = Import-Csv C:\Users\user\Desktop\dn2.csv
$finalzpa = Foreach($item in $list){
$zonezpa = Get-CdmZpaSetting -Zone $item.DistinguishedName
$zoneset = Get-CdmZone -dn $item.DistinguishedName
Get-CdmZone -Dn $item.DistinguishedName | %{
Get-CdmZpaSetting -Zone $item.DistinguishedName |
Select-Object @{Name='Userenabled';Expression={$zonezpa.UserEnabled}},
@{Name='Provisioning Groups enabled';Expression={$zonezpa.GroupEnabled}},
@{Name='ZoneName' ;Expression={$zoneset.Name}},
@{Name='User Source';Expression={$zonezpa.UserSource}},
@{Name='Group Source';Expression={$zonezpa.GroupSource}},
@{Name='Distinguished Name';Expression={$item.DistinguishedName}}
}}
$finalzpa | Export-Csv -Append -NoTypeInformation C:\Users\Desktop\zonesautoinfo.csv
To get to the actual issue I’m having. Below is the script that I created. The csv file contains the DN name ,Zone name and Group name.There are only two entries in the file for each row. There is a TEST and PROD group which also just has the dn listed.
When I run it, the results for the Get-CdmGroupProfile -Zone $item.DistinguishedName cmdlet show for both test and prod groups .
However the results that I put in the custom table at the end doesn’t work like it has in my previous experiences.So the Get-ADGroup $item.Group results don’t get captured,
When I run $adgroup.name , I get all of the groups for the group that is contained within the array,however the name property or any other property that is contained within the variable doesn’t automatically popup when putting in the dot that I’m used to getting.
The same thing happens for $centrifygprofile.I can type in $centrifygprofile.name or Zone and it displays that only.
I have seen this happen before ,but I have usually been able to get it to work by starting from scratch or removing all the variables and re-creating .
I’m not sure if this has anything to do with the scope or something else that might be obvious and I’m not seeing or understanding it.
If there is more information that is needed let me know.
This is the script that is working partially as in ,when I run it ,it doesn’t error out ,but it’s not selecting the custom column names and information from for the hash table.
None of the custom tables don’t get outputted to the csv file. I have used this script for other situations where I want to grab certain data and modify the name of the column.
None of the custom column headers that are listed are being added to the csv file.When I run $adgroup.name or $adgroup.distinguishedname by itself it shows the dn( $adgroup.distinguishedname )and groups ( $adgroup.name)when I use the commands by themselves.
I’m looking for
@{Name='ZoneName';Expression={$centrifygprofile.Zone}},
@{Name=' Centrify Group';Expression{$centrifygprofile.group}},
@{Name='AD Linux GROUP' ;Expression={$adgroup.name}},
@{Name='ADDistinguishedName';Expression{$adgroup.distinguishedname}}
$list = Import-Csv C:\Users\user\Desktop\Centrify\PEGA\Inputpega.csv
$result = foreach($item in $list) {
$adgroup = Get-ADGroupMember $item.Group
$centrifygprofile = Get-CdmGroupProfile -Zone $item.DistinguishedName
Get-ADGroup $item.Group | %{
Get-CdmGroupProfile -Zone $item.DistinguishedName |Select-Object
@{Name='ZoneName';Expression={$centrifygprofile.Zone}},
@{Name=' Centrify Group';Expression={$centrifygprofile.group}},
@{Name='AD Linux GROUP' ;Expression={$adgroup.name}},
@{Name='AD DistinguishedName';Expression={$adgroup.distinguishedname}}
}}
$result | Export-Csv C:\Users\user\Desktop\Centrify\PEGA\results2.csv -NoTypeInformation
Other information that may be needed -
$adgroup | gm
TypeName: Microsoft.ActiveDirectory.Management.ADPrincipal
Name MemberType Definition
---- ---------- ----------
Contains Method bool Contains(string propertyName)
Equals Method bool Equals(System.Object obj)
GetEnumerator Method System.Collections.IDictionaryEnumerator GetEnumerator()
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Item ParameterizedProperty Microsoft.ActiveDirectory.Management.ADPropertyValueCollection Item(string propertyName) {get;}
distinguishedName Property System.String distinguishedName {get;set;}
name Property System.String name {get;}
objectClass Property System.String objectClass {get;set;}
objectGUID Property System.Nullable`1[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] objectGUID {get;set;}
SamAccountName Property System.String SamAccountName {get;set;}
SID Property System.Security.Principal.SecurityIdentifier SID {get;set;}
$centrifygprofile | gm
TypeName: Centrify.DirectControl.PowerShell.Types.CdmGroupProfile
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
CanonicalName Property string CanonicalName {get;}
Computer Property Centrify.DirectControl.PowerShell.Types.CdmManagedComputer Computer {get;}
Domain Property string Domain {get;}
Gid Property System.Nullable[long] Gid {get;}
Group Property Centrify.DirectControl.PowerShell.Types.CdmGroup Group {get;}
IsHierarchical Property bool IsHierarchical {get;}
IsMembershipRequired Property System.Nullable[bool] IsMembershipRequired {get;}
IsOrphan Property bool IsOrphan {get;}
IsSfu Property bool IsSfu {get;}
Name Property string Name {get;}
PreferredServer Property string PreferredServer {get;}
Zone Property Centrify.DirectControl.PowerShell.Types.CdmZone Zone {get;}