Member_2_7968778
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(SupportsSho uldProcess =$True)]
Param(
[Parameter(Mandatory = $True)]
[String]$UserName
)
Import-Module ActiveDirectory
If ($UserName) {
$UserName = $UserName.ToUpper().Trim()
$Res = (Get-ADPrincipalGroupMembe rship $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-ADPrincipalGroupMember ship $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.
I found a script to read out memberships of a User from active directory as per below.
[CmdletBinding(SupportsSho
Param(
[Parameter(Mandatory = $True)]
[String]$UserName
)
Import-Module ActiveDirectory
If ($UserName) {
$UserName = $UserName.ToUpper().Trim()
$Res = (Get-ADPrincipalGroupMembe
If ($Res -GT 0) {
Write-Output "`n"
Write-Output "The User $UserName Is A Member Of The Following Groups:"
Write-Output "=========================
Get-ADPrincipalGroupMember
}
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Question answered.