I have a little script that exports a certain group to a csv file.
The question is if it is possible to insert a split in the group name to export twp groups into two separate csv files.
param (
[Parameter(Mandatory, ValueFromPipelineByPropertyname)]
[ValidateNotNullOrEmpty()]
[string]$GroupName
)
Get-ADGroupMember -identity “$GroupName” | select-object SamAccountName | Export-csv -path C:\Report\$GroupName.csv -NoTypeInformation
Is it possible to write " Group1 Group2 " and the export to two files, Group1.csv and Group2.csv?
$a = $GroupName.trim().split(" ")will give u an array of split items. Then$a[0]will give uGroup1and$a[1]will give uGroup2. So technically, you can send it to different csv - Sid