Archive for category PowerShell
PowerShell: Remove Google Chrome (any version)
Posted by edwgon in Browsers, PowerShell on October 27, 2020
The following PowerShell script will allow you to remove any installed version of Google Chrome.
Function UninstallChrome() {
$app = get-wmiobject Win32_Product | Where-Object {$_.Name -eq "Google Chrome"}
$removeChrome = $app.IdentifyingNumber msiexec /x
$removeChrome /q
}
# If chrome is running then close the process and uninstall it
If (Get-Process chrome -ErrorAction SilentlyContinue) {
# Chrome is running
# Stop chrome process
Stop-Process -Name chrome -Force
# Now uninstall chrome
UninstallChrome
} Else {
# Chrome is not running…
# Uninstall chrome
UninstallChrome
}
Install Hyper-V Role to Windows Server 2012 R2 During OS Deployment
Posted by edwgon in 64-bit, deploy, deployment, Hyper-V, management, Microsoft Deployment Toolkit, Microsoft System Center Configuration Manager 2012 R2 SP1, OS Deployment, PowerShell, sccm, SCCM 2012, server deployment, task sequence, virtual machine, virtual machines, Windows Server 2012 R2, Windows Server Feature on October 28, 2016
There are plenty of blogs about this subject, however, many of these blogs are outdated and some of their tips do not work properly for Windows Server 2012 R2. Also, in my case, I’m not using MSDT to install features and roles, but instead I’m using a captured WIM image.
To install Hyper-V role, just add a “Run Command Line” task, towards the end of the task sequence, Install Operating System task.
I’m using the following PowerShell command:
Powershell.exe -Command "& {&'Install-WindowsFeature' –Name Hyper-V -IncludeManagementTools -Restart}"
Also, here’s an interesting link that discusses this particular issue.
Run PowerShell Script in Schedule Tasks
Posted by edwgon in 64-bit, Microsoft, PowerShell, Scheduled Tasks, windows 7, windows 7 x64 on September 19, 2016
The following will allow you to run a Powershell script as a scheduled task. These instructions have been tested on a Windows 7 64bit computer.
Before proceeding, make sure your Powershell script runs without any errors. The best way to make sure your script is running fine is by calling it from a command prompt.
Note: Make sure you run Set-ExecutionPolicy from an elevated Powershell window to make sure your system (Windows 7) is allowed to run Powershell scripts.
- Open a Command Prompt window
- Run: powershell -file <your ps script file>
- Make sure it executes properly
Now, open Windows 7 Task Scheduler:
- In the Actions tab
- Power shell is found at: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
- You can also just use powershell.exe
- In Add arguments (optional) field, add the following: -File “C:\Path-to-your-script\Your-ps-script.ps1”
- Sample: -File “C:\Program Files (x86)\Info Folder\Get-Speed.ps1”
- In Start in (optional) field, add the following: C:\Program Files (x86)\Info Folder
- Sample: C:\Program Files (x86)\Info Folder
I’m not going to go over the other sections as this is the main section to be able to execute Powershell scripts from Schedule Tasks.
Get Active Network Adapter
Posted by edwgon in Microsoft, Microsoft System Center Configuration Manager 2012 R2 SP1, Network, powercli, PowerShell, SCCM 2012, Utilities, Windows Server 2008, Windows Server 2012 R2 on May 18, 2016
Recently I had the need to create a script to find out what was the active network adapter in our server, so after some ideas from the web, I came up with a one line PowerShell script that helped me achieve my goal.
Note: Get-NetAdapter is a PowerShell commandlet that’s present on Windows 8 and Windows Server 2012 R2. This command will not work on Windows 7.
Get-NetAdapter | Where-Object {($_.LinkSpeed -eq “1 Gbps”) -and ($_.Status -eq ‘Up’)}
In this line, I’m basically getting the adapter with status ‘Up’ and with a linkspeed equals to ‘1 Gbps’. One can change LinkSpeed property to match your server’s network adapter speed(s).
List All Disks (VMDKs) In A Virtual Machine (ESXi)
Posted by edwgon in administrator, disks, esxi, filename, http://schemas.google.com/blogger/2008/kind#post, powercli, PowerShell, virtual, virtual machines, vmdk, vmdks, vmware on March 31, 2015
Using VMware PowerCLI, PowerShell, there’s a nifty way to get a list of all VMDKs associated with a virtual machine(s).
Here’s the command:
For this sample, I chose to output the following fields:
From a GUID to its GPO name.
Posted by edwgon in Group Policy Object, GUID, http://schemas.google.com/blogger/2008/kind#post, PowerShell, Windows Server 2008 on December 11, 2012
Numerous times I had the issue, when troubleshooting a group policy object error, in which I only had the GPO’s GUID, but not its actual name. Well, it turns out that there is a powershell applet that performs a search in AD, using the GUID, and it returns the GPO’s full description for you.
- Open Widnows PowerShell Modules
- Type: get-gpo
- Paste that GUID and press ENTER
SCCM 2012 – Software Center Options
Posted by edwgon in Configuration manager 2012, OS Deployment, PowerShell, SCCM 2012, SCCM Client, Software Center on August 22, 2012
The original information came from this source, I’m just adding a few more screenshots for my benefit.
The following script will allow you to change a particular setting found in SCCM 2012’s Software Center.

$getStatus = Invoke-WmiMethod -Namespace "Root\ccm\ClientSDK" -Class CCM_ClientUXSettings -Name GetAutoInstallRequiredSoftwaretoNonBusinessHours -ComputerName $env:ComputerName -ErrorAction STOP If ($getStatus.AutomaticallyInstallSoftware -eq "True") { Write-Host "Compliant" } Else { Write-Host "Non-Compliant" }

Invoke-WmiMethod -Namespace “Root\ccm\ClientSDK” -Class CCM_ClientUXSettings -Name SetAutoInstallRequiredSoftwaretoNonBusinessHours -ArgumentList @($TRUE) -ComputerName $env:ComputerName -ErrorAction STOP


Recent Comments