PowerShell stuph...: Difference between revisions
No edit summary |
|||
(13 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<center>'''Do ''not'' use these scripts if you do not understand 100% what they do ! '''</center> | |||
[http://www.howtogeek.com/141495/geek-school-writing-your-first-full-powershell-script/ Go here] to get started on PowerShell. | |||
= Scripts i (ab)use = | = Scripts i (ab)use = | ||
<blockquote> | <blockquote> | ||
{| class="mw-collapsible mw-collapsed wikitable" | |||
! Setting network type using PowerShell --> | |||
|- | |||
| Open PowerShell with ''administrative privileges'' | |||
Run the following command: | |||
<pre>Get-NetConnectionProfile</pre> | |||
Find the network ''Name'' where you want to change its type and run the following command: | |||
<pre>Set-NetConnectionProfile -Name "ChangeThis" -NetworkCategory Public</pre> | |||
Where ''ChangeThis'' is the name of your network. | |||
You can change the -NetworkCategory switch value to Public or Private. | |||
|} | |||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! Config NIC as DHCP Client --> | ! Config NIC as DHCP Client --> | ||
Line 75: | Line 89: | ||
Get-AppxPackage *xboxapp* | Remove-AppxPackage | Get-AppxPackage *xboxapp* | Remove-AppxPackage | ||
Get-AppxPackage *candy* | Remove-AppxPackage | Get-AppxPackage *candy* | Remove-AppxPackage | ||
Get-AppxPackage *sway* | Remove-AppxPackage</pre> | Get-AppxPackage *sway* | Remove-AppxPackage | ||
Get-AppxPackage *solitaire* | Remove-AppxPackage | |||
Get-AppxPackage *messaging* | Remove-AppxPackage | |||
Get-AppxPackage *WindowsSoundRecorder* | Remove-AppxPackage | |||
Get-AppxPackage *windowscommunicationsapps* | Remove-AppxPackage | |||
Get-AppxPackage *YourPhone* | Remove-AppxPackage | |||
Get-AppxPackage *sticky* | Remove-AppxPackage | |||
Get-ProvisionedAppxPackage -Online | Where-Object { $_.PackageName -match "xbox" } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -PackageName $_.PackageName } | |||
Get-AppxPackage | Where-Object { $_.Name -match "xbox" } | Remove-AppxPackage | |||
</pre> | |||
|} | |||
{| class="mw-collapsible mw-collapsed wikitable" | |||
! Uninstall OneDrive (Commandline script) --> | |||
|- | |||
| <pre>REM *** Uninstall OneDrive *** | |||
start /wait "" "%SYSTEMROOT%\SYSWOW64\ONEDRIVESETUP.EXE" /UNINSTALL | |||
rd C:\OneDriveTemp /Q /S >NUL 2>&1 | |||
rd "%USERPROFILE%\OneDrive" /Q /S >NUL 2>&1 | |||
rd "%LOCALAPPDATA%\Microsoft\OneDrive" /Q /S >NUL 2>&1 | |||
rd "%PROGRAMDATA%\Microsoft OneDrive" /Q /S >NUL 2>&1 | |||
reg add "HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\ShellFolder" /f /v Attributes /t REG_DWORD /d 0 >NUL 2>&1 | |||
reg add "HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\ShellFolder" /f /v Attributes /t REG_DWORD /d 0 >NUL 2>&1 | |||
echo OneDrive has been removed. Windows Explorer needs to be restarted. | |||
pause | |||
start /wait TASKKILL /F /IM explorer.exe | |||
start explorer.exe</pre> | |||
Credits: https://gist.github.com/matthewjberger/2f4295887d6cb5738fa34e597f457b7f#file-remove-windows10-bloat-bat-L124 | |||
|} | |} | ||
</blockquote> | </blockquote> | ||
[[Category:Windows]] | [[Category:Windows]] |
Latest revision as of 11:50, 20 January 2024
Go here to get started on PowerShell.
Scripts i (ab)use
Setting network type using PowerShell --> Open PowerShell with administrative privileges Run the following command:
Get-NetConnectionProfileFind the network Name where you want to change its type and run the following command:
Set-NetConnectionProfile -Name "ChangeThis" -NetworkCategory PublicWhere ChangeThis is the name of your network. You can change the -NetworkCategory switch value to Public or Private.
Config NIC as DHCP Client --> $IPType = "IPv4" $adapter = Get-NetAdapter | ? {$_.Status -eq "up"} $interface = $adapter | Get-NetIPInterface -AddressFamily $IPType If ($interface.Dhcp -eq "Disabled") { # Remove existing gateway If (($interface | Get-NetIPConfiguration).Ipv4DefaultGateway) { $interface | Remove-NetRoute -Confirm:$false } # Enable DHCP $interface | Set-NetIPInterface -DHCP Enabled # Configure the DNS Servers automatically $interface | Set-DnsClientServerAddress -ResetServerAddresses }
Config NIC with static IP --> $IP = "172.29.106.41" $MaskBits = 27 # 24 = 255.255.255.0 | 27 = 255.255.255.224 $Gateway = "172.29.106.62" $Dns = "172.29.10.69" $IPType = "IPv4" # Retrieve the network adapter that you want to configure $adapter = Get-NetAdapter | ? {$_.Status -eq "up"} # Remove any existing IP, gateway from our ipv4 adapter If (($adapter | Get-NetIPConfiguration).IPv4Address.IPAddress) { $adapter | Remove-NetIPAddress -AddressFamily $IPType -Confirm:$false } If (($adapter | Get-NetIPConfiguration).Ipv4DefaultGateway) { $adapter | Remove-NetRoute -AddressFamily $IPType -Confirm:$false } # Configure the IP address and default gateway $adapter | New-NetIPAddress ` -AddressFamily $IPType ` -IPAddress $IP ` -PrefixLength $MaskBits ` -DefaultGateway $Gateway # Configure the DNS client server IP addresses $adapter | Set-DnsClientServerAddress -ServerAddresses $DNS
Uninstall Win 10 CrapWare --> Get-AppxPackage *3dbuilder* | Remove-AppxPackage Get-AppxPackage *windowsalarms* | Remove-AppxPackage Get-AppxPackage *windowscommunicationsapps* | Remove-AppxPackage Get-AppxPackage *windowscamera* | Remove-AppxPackage Get-AppxPackage *officehub* | Remove-AppxPackage Get-AppxPackage *skypeapp* | Remove-AppxPackage Get-AppxPackage *getstarted* | Remove-AppxPackage Get-AppxPackage *zunemusic* | Remove-AppxPackage Get-AppxPackage *windowsmaps* | Remove-AppxPackage Get-AppxPackage *bingfinance* | Remove-AppxPackage Get-AppxPackage *zunevideo* | Remove-AppxPackage Get-AppxPackage *bingnews* | Remove-AppxPackage Get-AppxPackage *onenote* | Remove-AppxPackage Get-AppxPackage *people* | Remove-AppxPackage Get-AppxPackage *windowsphone* | Remove-AppxPackage Get-AppxPackage *photos* | Remove-AppxPackage Get-AppxPackage *bingsports* | Remove-AppxPackage Get-AppxPackage *bingweather* | Remove-AppxPackage Get-AppxPackage *xboxapp* | Remove-AppxPackage Get-AppxPackage *candy* | Remove-AppxPackage Get-AppxPackage *sway* | Remove-AppxPackage Get-AppxPackage *solitaire* | Remove-AppxPackage Get-AppxPackage *messaging* | Remove-AppxPackage Get-AppxPackage *WindowsSoundRecorder* | Remove-AppxPackage Get-AppxPackage *windowscommunicationsapps* | Remove-AppxPackage Get-AppxPackage *YourPhone* | Remove-AppxPackage Get-AppxPackage *sticky* | Remove-AppxPackage Get-ProvisionedAppxPackage -Online | Where-Object { $_.PackageName -match "xbox" } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -PackageName $_.PackageName } Get-AppxPackage | Where-Object { $_.Name -match "xbox" } | Remove-AppxPackage
Uninstall OneDrive (Commandline script) --> REM *** Uninstall OneDrive *** start /wait "" "%SYSTEMROOT%\SYSWOW64\ONEDRIVESETUP.EXE" /UNINSTALL rd C:\OneDriveTemp /Q /S >NUL 2>&1 rd "%USERPROFILE%\OneDrive" /Q /S >NUL 2>&1 rd "%LOCALAPPDATA%\Microsoft\OneDrive" /Q /S >NUL 2>&1 rd "%PROGRAMDATA%\Microsoft OneDrive" /Q /S >NUL 2>&1 reg add "HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\ShellFolder" /f /v Attributes /t REG_DWORD /d 0 >NUL 2>&1 reg add "HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\ShellFolder" /f /v Attributes /t REG_DWORD /d 0 >NUL 2>&1 echo OneDrive has been removed. Windows Explorer needs to be restarted. pause start /wait TASKKILL /F /IM explorer.exe start explorer.exe