Starting with Windows Server 2012 R2 and Windows 8.1, PowerShell ships with many useful cmdlets for client and server configuration. This comes handy as some settings can no longer be controlled via UI. 从 Windows Server 2012 R2 和 Windows 8.1 开始,随着 PowerShell 发布了许多有用的客户端和服务器配置 cmdlet。这些 cmdlet 十分趁手,因为一些设置可以不再通过 UI 来控制。
例如,要改变网络的类型,只需要以管理员身份运行以下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
PS> Get-NetConnectionProfile
Name : internet-cafe InterfaceAlias : WiFi InterfaceIndex : 13 NetworkCategory : Private IPv4Connectivity : Internet IPv6Connectivity : Internet
PS> Get-NetConnectionProfile | Set-NetConnectionProfile-NetworkCategory Public -WhatIf What if:
PowerShell 可能是最简单的移除预装 Windows 10 APP 的方法。如果您知道想要移除的应用程序名称,只需要以管理员身份打开 PowerShell,然后像这样移除 APP:
1 2 3 4
PS> Get-AppxPackage *bingweather* | Remove-AppxPackage-WhatIf What if: Performing the operation "Remove package" on target "Microsoft.BingWeather_4.20.1102.0_x64__8wekyb3d8bbwe".
Type User Info Target
---- ---- ---- ------
Domain Extended Credentials tabcabcabc@hicsawr.com Saved for this logon only Mi
Domain Extended Credentials 02jbqxcbqvsb Saved for this logon only Mi
Generic tabcabcabc@hicsawr.com Local machine persistence Le
Generic Local machine persistence Le
Generic Local machine persistence Le
Generic Local machine persistence Le
Generic tabcabcabc@hicsawr.com Local machine persistence Le
Generic Local machine persistence Le
Generic 02jdrxcbqvsb Local machine persistence Wi
Generic Martin Le
Domain Password Martin Do
Domain Password Martin Do
Domain Password User Do
Name : pscredentialmanager Version : 1.0.1 Type : Module Description : This module allows management and automation of Windows cached credentials. Author : Adam Bertram CompanyName : adamtheautomator Copyright : (c) 2017 Adam Bertram. All rights reserved. PublishedDate : 18.06.201722:14:27 ...
Version Name Repository Description -------------------------------- 1.0.1 pscredentialmanager PSGallery This module allows 0.6 pscredentialmanager PSGallery This module allows 0.2 pscredentialmanager PSGallery This module allows
安装完成后,以下命令可以返回一个新 cmdlet 的列表:
1 2 3 4 5 6 7
PS> Get-Command-Module pscredentialmanager
CommandType Name Version Source ---------------------------- FunctionGet-CachedCredential0.6pscredentialmanager FunctionNew-CachedCredential0.6pscredentialmanager FunctionRemove-CachedCredential0.6pscredentialmanager
您现在可以管理缓存的凭据。例如要返回一个缓存的凭据列表,请试试以下代码:
1 2 3 4 5 6 7
PS> Get-CachedCredential
Name : SSO_POP_User Category : MicrosoftAccount Type : Domain Extended Credentials (...)