2023-03-14

Check for App Version on Windows

 I need a powershell to check for an application version

Sure, here's an example PowerShell script that you can use to check the version of an application:


bash

$applicationName = "Your Application Name"

$applicationPath = "C:\Program Files\Your Application Path\YourApplication.exe"

$applicationVersion = (Get-Item $applicationPath).VersionInfo.FileVersion


Write-Host "The current version of $applicationName is $applicationVersion."

In this script, you need to replace the placeholders with the actual name and path of the application that you


==================

can we check the version by looking on the registry?

Yes, you can also check the version of an application by looking it up in the registry. Here's an example PowerShell script that retrieves the version of an application from the registry:


bash

Copy code

$applicationName = "Your Application Name"

$registryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"

$applicationKey = Get-ChildItem $registryPath | Where-Object {$_.GetValue("DisplayName") -eq $applicationName}


if ($applicationKey) {

    $applicationVersion = $applicationKey.GetValue("DisplayVersion")

    Write-Host "The current version of $applicationName is $applicationVersion."}

else 

    {Write-Host "Could not find $applicationName in the registry."}



In this script, you need to replace the $applicationName variable with the name of the application you want to check. The script searches for the application in the Uninstall key of the registry, and retrieves the DisplayVersion value, which typically contains the application version number.

Note that the location of the Uninstall key may vary depending on the application and the version of Windows you are using, so you may need to modify the $registryPath variable if the key is located elsewhere.


PSRemoting (Run PowerShell Remotely)

 Donds how can i activate to run powershell remotely

To enable PowerShell remoting on a remote computer, you can use the Enable-PSRemoting cmdlet. Here are the steps to follow:

Open an elevated PowerShell session on the remote computer. You can do this by right-clicking on the PowerShell icon and selecting "Run as Administrator".

Run the Enable-PSRemoting cmdlet. This will configure the WinRM service to allow remote access and create the necessary firewall rules.

Enable-PSRemoting -Force

If prompted, type "y" to confirm that you want to make changes to the computer.

Once the cmdlet has completed, you can test the connection from your local computer by running the following command:

Test-WSMan -ComputerName RemoteComputerName

Replace "RemoteComputerName" with the name or IP address of the remote computer. If the connection is successful, you should see a message that says "WSMAN:$RemoteComputerName\Service is OK".

You can now run PowerShell commands and scripts remotely using the Invoke-Command cmdlet. For example: sql

Invoke-Command -ComputerName RemoteComputerName -ScriptBlock { Get-Process }

This will run the Get-Process cmdlet on the remote computer and return the list of running processes.

Note that enabling PowerShell remoting on a remote computer may pose a security risk, so it is important to follow best practices and limit access to authorized users only.