MilesLogan
asked on
Powershell - Pull date modified for profiles in C:\users
Hi EE
Anyone have a PS script or utility that I can use to pull the Date modified for all profiles in C:\Users for multiple servers ?
Anyone have a PS script or utility that I can use to pull the Date modified for all profiles in C:\Users for multiple servers ?
Of course that will only work locally. To apply it to a list of servers (and have improved output), you would need something like:
Get-WmiObject -ComputerName (get-content c:\Servers.txt) Win32_UserProfile | % {
$userinfo = [WMI] ($_.__Path -Replace "Win32_UserProfile", "Win32_SID")
New-Object PsObject -Property @{
ComputerName= $_.__Server
Domain = $userinfo.ReferencedDomainName
User = $userinfo.AccountName
LastUsed = $_.ConvertToDatetime($_.LastUseTime)
}
}
ASKER
Thank you both, I was able to get output from ThinkSpaceSolutions for the local machine but I do need it for multiple machines so I was needing something like Qlemo's example ..
Qlemo please see the error below.
Get-WmiObject : Invalid class "Win32_UserProfile"
At C:\test\Qlemo_test.ps1:1 char:1
+ Get-WmiObject -ComputerName (get-content c:\test\Servers.txt) Win32_UserProfile ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~
+ CategoryInfo : InvalidType: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException, Microsoft. PowerShell .Commands. GetWmiObje ctCommand
Qlemo please see the error below.
Get-WmiObject : Invalid class "Win32_UserProfile"
At C:\test\Qlemo_test.ps1:1 char:1
+ Get-WmiObject -ComputerName (get-content c:\test\Servers.txt) Win32_UserProfile ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,
Win32_UserProfile only to works with Vista/2008 and above.
ASKER
my bad .. I was testing it to pull data from an XP machine .. worked great for 2003/2008 server.. thanks ! can you help me export it to a CSV file ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
| export-csv -NoType c:\Results.csv lol .. I was close !
thank you so much !
thank you so much !
Open in new window