Link to home
Start Free TrialLog in
Avatar of Member_2_7968778
Member_2_7968778Flag for Malta

asked on

Powershell dump in C with variable name

Good Morning,

I found a script to read out memberships of a User from active directory as per below.


[CmdletBinding(SupportsShouldProcess=$True)]
Param(
       [Parameter(Mandatory = $True)]
       [String]$UserName
)
Import-Module ActiveDirectory
If ($UserName) {
       $UserName = $UserName.ToUpper().Trim()
       $Res = (Get-ADPrincipalGroupMembership $UserName | Measure-Object).Count
       If ($Res -GT 0) {
              Write-Output "`n"
              Write-Output "The User $UserName Is A Member Of The Following Groups:"
              Write-Output "==========================================================="
              Get-ADPrincipalGroupMembership $UserName | Select-Object -Property Name, GroupScope, GroupCategory | Sort-Object -Property Name | FT -A
       }
}

This has been tested and worked fine.

Please guide me on how to Save the outcome in C$ +with the usename variable.txt and then step two copy the txt file from C:\ to remote share (xcopy).

All this has to be within the same powershelll command.

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oBdA
oBdA

Question answered.