Jump to content
View in the app

A better way to browse. Learn more.

Pulseway

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I looked at this script, and it will always return "Operating system is not supported" because in the script $major and $minor are strings, I was able to confirm that with the commands:

$major.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object

 

$minor.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object

 

I recommend updating the script to this, and I highlighted the changes:

$version = (Get-WmiObject Win32_OperatingSystem).Version
[int]$major = $version.split(".")[0]
[int]$minor = $version.split(".")[1]
if ($major -gt 6 -or ($major -eq 6 -and $minor -gt 1)) {
    Optimize-Volume -driveletter $pwd.drive.name -Analyze -verbos
} Else {
    Write-Output "Operating system is not supported."
}

 

Here is the original script:

$version = (Get-WmiObject Win32_OperatingSystem).Version
$major = $version.split(".")[0]
$minor = $version.split(".")[1]
if ($major -gt 6 -or ($major -eq 6 -and $minor -gt 1)) {
    Optimize-Volume $pwd.drive.name -Analyze -verbos
} Else {
    Write-Output "Operating system is not supported."
}

 

REF: https://learn.microsoft.com/en-us/powershell/module/storage/optimize-volume?view=windowsserver2022-ps

REF: https://lazyadmin.nl/powershell/if-else-statements/

REF: https://theitbros.com/powershell-convert-string-to-int/

Edited by smcclos
Needed to clarify something

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.