I'm having an issue with this script. For some reason, it was working previously and now it is not. It is now returning with:
Invoke-GPUpdate : The term 'Invoke-GPUpdate' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
Write-Host "Refreshing Group Policies on the local machine......."
Invoke-GPUpdate -Computer $computer -RandomDelayInMinutes 0 -force ForegroundColor Cyan
Start-Sleep -s 20
Invoke-GPUpdate is part of the GroupPolicy module. GroupPolicy is not available by default, but is included with RSAT Tools. What likely happened is a major update to Windows occurred and in this case, if RSAT Tools isn't installed as a Windows Feature (it is only available as a "Feature on Demand" beginning with the Windows 10 October 2018 Update, which is build 17763), it will get removed during the update and needs to be re-installed.
This technically happens with the feature as well I believe, as RSAT Tools is still linked to specific versions of Windows, but the upgrade process will re-install the feature if it was already present.
Installing GroupPolicy RSAT Tools as a feature with Windows PowerShell
If you have Windows 1809 or newer, you can install as a feature using the following command:
Get-WindowsCapability -Name 'Rsat.GroupPolicy.*' -Online | Where-Object { $_.State -ne 'Installed' } | Add-WindowsCapability -Online
You can do the same with other RSAT Tools as well (the features are modularized per their functionality). To enumerate all of them:
Get-WindowsCapability -Name RSAT*
Once again, this requires Windows 1809 or newer or the features will be unavailable. You'll have to install it by using the MSU provided by Microsoft for your Windows version.
Related
I try to list all applications, choose one of them and uninstall it, kind of like in control panel.
$package = get-package | Out-GridView -PassThru
Get-Package -Name $package.Name | Uninstall-Package
when I execute this and choose Google Chrome, it doesn't do much.
this is probably a dumb question, not new to PowerShell but not veteran either
The Uninstall-Package cmdlet can't delete entries where "ProviderName" is "Programs"
Example:
get-package *chrome*
Name Version Source ProviderName
---- ------- ------ ------------
Google Chrome 105.0.5195.127 Programs
In general Programs with "ProviderName" property as "Programs" are ones that are installed via .exe .
If you want to uninstall packages with PackageManagement/PowerShellGet they need to be installed by PackageManagement/PowerShellGet.
Alternative would be to install Chocolatey Package Provider and it should be able to delete it
I am trying to uninstall packages using the PowerShell command and script. Every time I run the command it runs and does nothing moreover can't find any logs of it. I tried Microsoft documentation https://learn.microsoft.com/en-us/powershell/module/packagemanagement/uninstall-package?view=powershell-7.1 In stack overflow similar problem Powershell: Find installed Antivirus, filtering out Windows Defender to find the installed antivirus. But When I want to uninstall it simply does nothing.
# Get-Package -Provider Programs -IncludeWindowsInstaller
$appToRemove = Get-Package -IncludeWindowsInstaller -Name Avast
Write-Output $appToRemove
Uninstall-Package $appToRemove -Force -AllVersions -Confirm
I have tried several solutions and stuck for 1 week. Can anyone please help me? Thank you.
Before the recent update WSL root filesystem was always in C:\Users\%username%\AppData\Local\lxss, but now when Linux is installed from the App Store it can be different for each installation. For example for Ubuntu on my machine it is C:\Users\%username%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs
Is there a way to detect this path from within current WSL session?
As noted by other users, nowadays you can install multiple Linux distributions and each distribution have their own filesystem located in a different folder. The location of each filesystem can be obtained from the Windows Registry.
You can run regedit and look for the information. The data is located under
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss
In addition, you can start a PowerShell window and execute the following command to determine information of all the installed Linux distributions.
(Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss" -Recurse)
To obtain the location of the filesystems, you can run
(Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | ForEach-Object {Get-ItemProperty $_.PSPath}) | select DistributionName,BasePath
In PowerShell:
> echo ($env:LOCALAPPDATA + '\Packages\' + ($(get-appxpackage).PackageFamilyName|findstr UbuntuonWindows))
C:\Users\Reker\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
You can run above command in bash.exe on Windows 14393 or above by interop with windows cmd.exe or powershell.exe
I have Windows 10 and "Turn Windows Features on or off" is empty.
So I can't add/install MSMQ using it.
I don't know when "Windows Features" window become this (empty) so I can't use Windows Restore (I don't know what date to choose and I've installed some programs last days so I don't want to use it anyway)
Is there an alternative way to enable MSMQ?
Run Windows PowerShell as Administrator.
To get a list of available features, Type Get-WindowsOptionalFeature -online | ft
Enable-WindowsOptionalFeature -online -FeatureName XXXXXX
Replace XXXXXX with the feature you wish to enable.
Yeah.. "Windows Features & Installed updates" empty/blank issue should be fixed anyway. Pretty easy Solution (works 100%):
download iso of your Win OS, for e.g. Windows 10 -
https://www.microsoft.com/en-us/software-download/techbench - free
to download any Win 10 from official MS servers..
just open this iso, run Setup.exe (windows explorer can easily open iso files itself, so you don't need flash device or dvd) and just update your OS:
your files, installed programs/apps will not be removed :) it just reinstalls system files
source: https://support.microsoft.com/ru-ru/kb/957310 - check
"Способ 4. Выполнить обновление на месте" - yeah it's in Russian and I don't know why English version doesn't have it...
https://support.microsoft.com/en-hk/kb/957310
p.s.
sfc /scannow or DISM.exe /Online /Cleanup-image /Restorehealth- none of this helped me, but you could try it first and see if it helps
you can also try MS "System Update Readiness" tool https://support.microsoft.com/en-hk/kb/947821 (I didn't use it but mb it also can fix it)
Has anyone tried installing powershell on a Windows 2000 server? I realize its not supposed to be installed on windows 2000 server and therefore not supported; however the vbscript that runs on it takes 3.5 days to complete which powershell could probably finish in lesser time. Nevertheless, I noticed it just requires .NET 2.0 to run.
thanks in advance.
If you have administrator access to the Windows 2000 server in question, you could run PowerShell on a supported machine in the same domain and use set-location to change your working directory to the remote server
cd \\remoteserver\<drive>$\path\to\folder\you\want\to\start\in
You could then run whatever PowerShell script you want on the remote directory. If the folder you are starting in is shared, it is even simpler (you won't need to access the admin share). Or you could map a drive on your machine with PowerShell that links to the target directory.
This might be a smoother option than forcing an install on a non-supported machine.
Yes. This works. Instead of installing Powershell on the server, just remotely talk to it like :-
Set-Location "\\MyServer\D$\wwwportal\MyChangedFileFolder\"
Get-ChildItem -filter *.txt -Recurse