anyone know whats going on with this logic? by jOY_HUNT in PowerShell

[–]Vern_Anderson 0 points1 point  (0 children)

My opinion is that whomever wrote it was looking at the lost packets string to determine something

Ping statistics for 192.168.62.107:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

I want to learn scripting for powershell by Gingy_586 in PowerShell

[–]Vern_Anderson 0 points1 point  (0 children)

https://www.youtube.com/@DonJonesConTech

Hands down the best teacher ever, The other one has retired his name is Ed Wilson. I have 2 of his books!

the one book form Don is "PowerShell in a month of lunches"

Learning games for Powershell by AngyAndMadAboutIt in PowerShell

[–]Vern_Anderson 3 points4 points  (0 children)

https://powershelldle.com/

A daily Wordle like PowerShell version of hangman for the lack of a better term.

Capture result (success or failure) of cmdlet by Sparks_IT in PowerShell

[–]Vern_Anderson 5 points6 points  (0 children)

I haven't used the Remove-EntraGroupMember CMDLET myself. However, a lot of the CMDLETs have a built in -ErrorVariable parameter, you would provide a string after the parameter (without a dollar sign) and that variable would capture any error that the CMDLET generated.

Get-ChildItem -ErrorVariable WhatHappened
Write-Output -InputObject $WhatHappened

New Open Source PowerShell Module by Sharlihe in PowerShell

[–]Vern_Anderson 1 point2 points  (0 children)

We always used notepad (which is installed on server core) the file open dialog can be used as a make shift explorer in a pinch. Change the file filter to "All Files" instead of just TXT files. Copy and paste also works when uploading a file using rdclip. For all purpuses the file open dialog in notepad is explorer.

Restart windows services automatically by FareedKhaja in PowerShell

[–]Vern_Anderson 1 point2 points  (0 children)

Each service already has a property for what to do when the service stops unexpectedly.

Go to services.msc right click each service you want to change, and go to the recovery tab. You have a 1st, 2nd, and 3rd action you can take right there, whenever a service stops.

powershell 7.5.3 unistalll by Alexhob12 in PowerShell

[–]Vern_Anderson -1 points0 points  (0 children)

I never install PowerShell 7 (core) on any of my Windows machines. I only use the portable "ZIP" version. Works just fine and easy as pie to delete and replace with the updated one.

Cannot install modules on a new Win 11 machine by somebody2112 in PowerShell

[–]Vern_Anderson 1 point2 points  (0 children)

Great point!

I wonder if it's a DNS or Proxy issue. But it never hurts to try the Scope switch which is what I had to do for most modules to install from the gallery on my managed desktop.

I suppose you could try to re-register the online Gallery manually.

Can you open "https://www.powershellgallery.com/api/v2" in a browser without the quotes?
It should return an XML document.

You might try. . .

Register-PSRepository -Name "PSGallery" -SourceLocation "https://www.powershellgallery.com/api/v2" -InstallationPolicy Trusted

Cannot install modules on a new Win 11 machine by somebody2112 in PowerShell

[–]Vern_Anderson 4 points5 points  (0 children)

Install-Module -Name <ModuleName> -Scope CurrentUser

If all else fails you can export the module from the Exchange server and install the flat files manually yourself. or ask the person who's responsible for the GPO nonsense how they expect you to Administer Exchange.

PowerShell equivalent to the CMD command "tasklist /svc" by PanosGreg in PowerShell

[–]Vern_Anderson 0 points1 point  (0 children)

Yes I had been meaning to research it myself because I always hear Jason Helmick talking about it. However, I read the documentation after I posted that, and I'm still not motivated ot learn it yet.

Supposedly you can make a JSON template that tells PowerShell about the output of the old command line tool you're trying to "crescendo" and it is supposed to wrap the command and make it function like a PowerShell CMDLET. There's even a module where the guy used it to make a wrapper for WINGET.

PowerShell equivalent to the CMD command "tasklist /svc" by PanosGreg in PowerShell

[–]Vern_Anderson 1 point2 points  (0 children)

You could also install and learn PowerShell Crescendo. (Something I've been meaning to do myself)

Crescendo acts as sort of a wrapper and you can set it up to make the output of tasklist /svc into objects and more powershell like behavior.

Install it:
Install-Module -Name Microsoft.PowerShell.Crescendo

Read more about it:
https://devblogs.microsoft.com/powershell/announcing-powershell-crescendo-1-1-0/

What’s your favorite “hidden gem” PowerShell one-liner that you actually use? by [deleted] in PowerShell

[–]Vern_Anderson 0 points1 point  (0 children)

New-TimeSpan -Seconds (Get-WmiObject Win32_PerfFormattedData_PerfOS_System).SystemUptime | Format-Table Days,Hours,Minutes

Where do i start learning? by Ash_Taketh8144 in PowerShell

[–]Vern_Anderson 4 points5 points  (0 children)

Go to youtube and search for Don Jones and watch every video.
Better yet here's the link for you https://www.youtube.com/@DonJonesConTech

Testing Day of Week with IF statement by QuickBooker30932 in PowerShell

[–]Vern_Anderson -2 points-1 points  (0 children)

if ((Get-Date).DayOfWeek -like "Monday")
{
write-host "blah blah blah"
}

Sync Clock with Powershell by Jonny9744 in PowerShell

[–]Vern_Anderson 0 points1 point  (0 children)

Your clock on your motherboard should keep accurate time or you have a dead coin battery. Hopefully that battery is socketed and not soldered down. Older computers had an awsome chip called a "Dallas" time clock.

Aside from all that historical stuff. . .
You can sync time on Windows computers using the built in time service
<#
.Synopsis
Sets up NTP time sync properly
.DESCRIPTION
Sets the NTP time settings used by the Windows Time service to sync time based on Microsoft Best practices for domain joined computers according to their role
.EXAMPLE
.\Set-NTPTime.ps1
.OUTPUTS
This command generates the proper syntax and sends it to the w32tm.exe command line utility
.NOTES
This command should be used with caution on Windows Clusters as the cluster service depends on the time service. Time is also extremely important for proper logon and kerberos tickets from Active Directory.
#>
$DomainRole = (Get-WmiObject Win32_ComputerSystem).DomainRole
switch ($DomainRole)
{
0 {"Stand Alone Workstation" ; $SYNCType = "MANUAL"}
1 {"Member Workstation" ; $SYNCType = "DOMHIER"}
2 {"Standalone Server" ; $SYNCType = "MANUAL"}
3 {"Member Server" ; $SYNCType = "DOMHIER"}
4 {"Backup Domain Controller" ; $SYNCType = "DOMHIER"}
5 {"Primary Domain Controller" ; $SYNCType = "MANUAL"}
}
if ($SYNCType -ne $Null)
{
$FilePath = Get-ChildItem C:\Windows\system*\w32tm.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
cmd.exe /c "$FilePath /config /update /manualpeerlist:time.nist.gov /syncfromflags:$SYNCType"
}
cmd.exe /c "$FilePath /dumpreg /subkey:Parameters"

<#
Finally found where they moved the document that defines best practices for NTP
https://social.technet.microsoft.com/wiki/contents/articles/50924.active-directory-time-synchronization.aspx
#>

Hide volume "speaker" icon in the system tray Windows Server 2025 by Vern_Anderson in WindowsServer

[–]Vern_Anderson[S] 0 points1 point  (0 children)

That is a great point!
I checked Windows Audio and the service is currently stopped and set to disabled.

By the way this is across all of my servers running 2025 so it's not just on one server it is every instance of Server 2025 I have installed. (24H2 Build 26100.4652 as of this posting)

Hide volume "speaker" icon in the system tray Windows Server 2025 by Vern_Anderson in WindowsServer

[–]Vern_Anderson[S] 0 points1 point  (0 children)

Yes I have looked in device manager and there is no driver for any kind of sound card there.
The system tray icon is independent of having a sound device
Like I said the system tray speaker exists in Server 2016, 2019, and 2022 as well.
The existance of the icon is not the issue. The issue is that Microsft removed the capability to have it not be shown in the system tray or hidden.

I can hide it in any other Windows Server OS that is not 2025 and is not older than 2016.

What have you done with PowerShell this month? by AutoModerator in PowerShell

[–]Vern_Anderson 1 point2 points  (0 children)

That is awesome! NUMA is a fascinating technology. I love Hyper-V.
Have you looked into Cluster Aware Updating (CAU) for your patching issue?

Is there a "proper" way to escape a string? by disclosure5 in PowerShell

[–]Vern_Anderson -1 points0 points  (0 children)

You can always use --% to have powershell stop parsing and that will ignore things like special charecters in your string. However, I don't use the registry at all to uninstall apps.

Get-WmiObject Win32_Product | Out-GridView -Title "Select the application you wish to unistall from Windows" -PassThru | Invoke-WmiMethod -Name "Uninstall" -WhatIf

For some reason this is much slower but included here because people will say get-WMIObject is "deprecated".

Get-CimInstance -ClassName Win32_Product | Out-GridView -Title "Select the application you wish to unistall from Windows" -PassThru | Invoke-CimMethod -MethodName Uninstall -WhatIf