Reputation: 515
I am trying to get something like this to work but cannot figure it out.
(Get-Item env:userprofile\AppData\Local\Microsoft\OneDrive\OneDrive.exe).VersionInfo.FileVersion
I am getting an error that it does not exist, though I know it does.
If I run the same thing with a known logged in user like below,
(Get-Item c:\users\jonesb\AppData\Local\Microsoft\OneDrive\OneDrive.exe).VersionInfo.FileVersion
I get the versioning I am looking for. I will be running this script on thousands of machines and I don't know who will be logged in to each machine. Please advise.
Upvotes: 0
Views: 282
Reputation: 3154
env:userprofile
expands to env:\userprofile
. This is a PSDrive, which you can access with Cmdlets like Get-Item
, but it does not expand in strings. What you need to do is to use the variable $env:userprofile
.
(Get-Item $env:userprofile\AppData\Local\Microsoft\OneDrive\OneDrive.exe).VersionInfo.FileVersion
Upvotes: 2