Pages

Sunday, July 3, 2016

Uninstall an application from PowerShell–Example Windows Live Essential

I was trying to see an option to uninstall and application from the PowerShell after couple of try I got through.

1. Run PowerShell as administrator

2. Get the status of installation, in this example we are trying to check status of Windows Live Essentials installation so enter as,

“Get-WmiObject -Class win32_product | where { $_.Name -like "*Windows Live Essentials*"}”

clip_image001

3. Store the current installation status to a variable, this example ‘$Software’ is the variable
“$software = Get-WmiObject -Class win32_product | where { $_.Name -like "*Windows Live Essentials*"}”

clip_image002

4. Run “$software.Uninstall()” to un install

clip_image004

5. Execute the step 2 to see the status again

Friday, July 1, 2016

Error while running a PowerShell script with 'curl'

This week I was working on a script to back-up a Audiocodes gateway, while running the script I got below error and it took a day of mine to troubleshooting the issue.

Invoke-WebRequest : Cannot bind parameter 'WebSession'. Cannot convert the "%{http_code}" value of type "System.String" to type "Microsoft.PowerShell.Commands.WebRequestSession".At C:\scripts\Untitled4.ps1:20 char:50+ $statuscode = curl -o null.txt $loginurl -w '%{http_code}'+ ~~~~~~~~~~~~~~+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

clip_image001

Solution which worked for me

After digging lot into the issue came to know that the issue was due to an Alias of ‘curl’

To solve the issue run "Remove-Item alias:curl" from the same PowerShell window or write curl.exe instead of writing just 'curl'

Hope this will help you Winking smile

Sunday, June 26, 2016

Enable Hyper-v feature from PowerShell

As you may probably know Hyper-v comes with Windows 10 as Windows feature and if you would like to enable the same from PowerShell then its possible. You can also enable the feature from graphical way but here I am going to mention how its possible by using PowerShell.

1. Run PowerShell as administrator

2. Type “Get-WindowsOptionalFeature -Online |where featureName -Like "*hyper*" |ft” and hit enter. It will show the current status

image
3. Type “enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All -All –Verbose” and hit enter. Enter “Y” when prompted
image

4. Enter “Get-WindowsOptionalFeature -Online |where featureName -Like "*hyper*" |ft” gain to see the status, it should show all enabled
image

Enjoy the Hyper-v feature Smile