Skip to content

Use WMI in Get-Uptime on Windows - #24644

Closed
Ilya (iSazonov) wants to merge 1 commit into
PowerShell:masterfrom
iSazonov:getuptime-wmi
Closed

Ilya (iSazonov) wants to merge 1 commit into
PowerShell:masterfrom
iSazonov:getuptime-wmi

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Dec 5, 2024 •

Copy link
Copy Markdown
Collaborator

PR Summary

Fix #24432

PR Context

The stopwatch has a significant drift in Windows over time so it is better use WMI request.

PR Checklist

@jborean93

Copy link
Copy Markdown
Collaborator

Just as an FYI, WMI is typically not accessible for non-admins in a non-interactive session like ssh/PSRemoting.

@iSazonov

Copy link
Copy Markdown
Collaborator Author

Payment for accuracy. :-)

Another official API I know (Get-CimInstance Win32_PerfFormattedData_PerfOS_System).SystemUpTime requires remote permissions too.
An unofficial way is to view the c:\pagefile.sys file time.

Do you know any other ways that we could use?

@jborean93

Copy link
Copy Markdown
Collaborator

I'm not aware of any but I've not really had a look before. I just know that in Ansible we've tried to reduce our use of WMI because it doesn't work on a network logon unless the user is an administrator. I guess it's a question here if the cmdlet should get the more accurate information at the cost of erroring in a PSRemoting session or whether it should have a fallback in case that fails.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Review - Needed The PR is being reviewed label Dec 16, 2024
@iSazonov

Copy link
Copy Markdown
Collaborator Author

We need more discuss in related issue.

@microsoft-github-policy-service microsoft-github-policy-service Bot removed the Review - Needed The PR is being reviewed label Dec 25, 2024
@microsoft-github-policy-service

microsoft-github-policy-service Bot commented Dec 25, 2024 •

Copy link
Copy Markdown
Contributor

📣 Hey Ilya (@iSazonov), how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get-Uptime is very slightly but increasingly inaccurate relative to Task Manager's up time

4 participants