Answered by:
Powershell help - filtering and displaying special output of Get-WMIObject win32_userprofile

-
Is there a way i can filter the outputted data of the following and only display the username?
So..
Get-WMIObject win32_userprofile -filter "special = false" |
Select-Object LocalPathDisplays
c:\Users\charliebrown
when i need it to display
charliebrown
Is this possible with where and can someone please point me in the right direction?
Question
Answers
-
Get-WMIObject win32_userprofile -filter "special = false" | Select-Object LocalPath | Foreach { $_.LocalPath.SPlit('\')[2] }
If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''
- Marked as answer by Ashleyheartspowershell Thursday, February 15, 2018 2:55 PM
-
$pathnames = 'joe','john','james'$samnames = 'joe','john','roger'$pathnames | foreach { $samnames -eq $_ }
joejohn- Marked as answer by Ashleyheartspowershell Thursday, February 15, 2018 2:55 PM
-
This seems to work. Copy these two folders (there's a GAC_32 as well). Note that regular users can run some of the commands.
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ActiveDirectory
C:\Windows\Microsoft.NET\assembly\GAC_64\Microsoft.ActiveDirectory.Management
- Edited by JS2010 Tuesday, February 13, 2018 4:16 PM
- Marked as answer by Ashleyheartspowershell Thursday, February 15, 2018 2:55 PM
All replies
-
Get-WMIObject win32_userprofile -filter "special = false" | Select-Object LocalPath | Foreach { $_.LocalPath.SPlit('\')[2] }
If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''
- Marked as answer by Ashleyheartspowershell Thursday, February 15, 2018 2:55 PM
-
-
$User = Get-WMIObject win32_userprofile -filter "special = false" | Select-Object -ExpandProperty LocalPath | Split-Path -Leaf Get-Aduser -identity $User -properties Enabled
Regards kvprasoon
- Edited by PRASOON KARUNAN V Thursday, February 8, 2018 6:33 PM
-
$pathnames = 'joe','john','james'$samnames = 'joe','john','roger'$pathnames | foreach { $samnames -eq $_ }
joejohn- Marked as answer by Ashleyheartspowershell Thursday, February 15, 2018 2:55 PM
-
Get-ADUser : Cannot convert 'System.Object[]' to the type 'Microsoft.ActiveDirectory.Management.ADUser' required by parameter 'Identity'. Specified method is not supported. At C:\Users\blah\Desktop\blah.ps1:3 char:22 + Get-Aduser -identity $User -properties Enabled + ~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-ADUser], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.GetADUser
-
-
-
-
-
-
Simple,
1. Get the user same using WMI($User = Get-WMIObjectwin32_userprofile -filter "special = false" | Select-Object -ExpandProperty LocalPath | Split-Path -Leaf )
2. Iterate through each user and check that user is Enabled or not in Active Directory
Regards kvprasoon
-
-
Are you saying i can't match a disabled user to Get-WMIObject userprofile? I am new to powershell and simply trying to match a way for a user profile to run against the ad user's list to determine if any are disabled. If they are i need it to list and prompt for each user to remove. Is there a better direction you can point me in?
-
-
-
Yes, you can do it in two ways.
1. Using Import-PSSession
#Create a session to the DC $Session = New-PSSession -ComputerName <Adserver> #Import the specified module from that session Import-PSSession -Session $Session -Module ActiveDirectory
2. Using Import-Module
#Creates session to ADServer $Session = New-PSSession -ComputerName <AdServer> #Imports ActiveDirectory module using created Session Import-Module -Name ActiveDirectory -PSSesison $Session
We would like you to do below exercise first.
Get-Help Import-PSSession -Full Get-Help Import-Module -Full
Regards kvprasoon
-
-
This seems to work. Copy these two folders (there's a GAC_32 as well). Note that regular users can run some of the commands.
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ActiveDirectory
C:\Windows\Microsoft.NET\assembly\GAC_64\Microsoft.ActiveDirectory.Management
- Edited by JS2010 Tuesday, February 13, 2018 4:16 PM
- Marked as answer by Ashleyheartspowershell Thursday, February 15, 2018 2:55 PM