Fork me on GitHub

windows管理方式

windows管理方式演进

mmc,在运行里输入mmc,进行添加管理单元
rdp
powershell
servermanager

=================================

windows中凭据的概念就是用户名与密码
应用程序或脚本来请求凭据

1、远程桌面请求凭据
2、powershell请求凭据


PS C:\Windows\system32> get-credential

位于命令管道位置 1 的 cmdlet Get-Credential
请为以下参数提供值:
Credential

UserName Password
-------- --------
administrator System.Security.SecureString

 

[DESKTOP-6G8GBI3]: PS C:\Users\Administrator\Documents> Get-Credential

Windows PowerShell 凭据请求: 位于命令管道位置 1 的 cmdlet Get-Credential
警告: 远程计算机 DESKTOP-6G8GBI3 上的脚本或应用程序正在请求凭据。只有在你信任远程计算机以及请求凭据的应用程序或脚本时,才应输入你的凭据。

 

=================================

winrm
cd wsman:
Get-Service
start-service
Enable-PSRemoting
Get-Credential
enter-pssession
get-item
set-item

========================================

 

powershell连接远程机器

========================================
远程cmd下

#在命令行里运行
powershell

#看一下ip地址,并记ip地址
ipconfig

#确认WinRM是启动的
Get-Service WinRM | start-Service

#最后,你需要允许远程运行PowerShell
Enable-PSRemoting


----------------------------------------------------------------------
本地cmd下

powershell

# 确认WinRM在你的电脑上是启动的
Get-Service WinRM | Start-Service

# 非域控环境下添加trusted host(如果是域控把"*"改为域名即可)
Set-Item WSMan:\localhost\Client\TrustedHosts "*" -Force

本地命令行下
如何将计算机添加到受信任主机列表,相当于ssh连接时的警告一样,首次添加,后续不用了

PS C:\Windows\system32> get-item WSMan:\localhost\Client\TrustedHosts
PS C:\Windows\system32> Set-Item WSMan:\localhost\Client\TrustedHosts -value llc-nb

set-item wsman:\localhost\Client\TrustedHosts -value 192.168.6.23
PS C:\Users\Administrator
> Enter-PSSession 位于命令管道位置 1 的 cmdlet Enter-PSSession 请为以下参数提供值: ComputerName: llc-nb [llc-nb]: PS C:\Users\Administrator\Documents>

 

 

PS C:\Users\Administrator> get-help Get-Credential
Gets a credential object based on a user name and password.

credential n. 证书;凭据;国书


# 试一下连接远程服务器的powershell,记得在弹出窗里输入远程服务器的帐号密码
Enter-PSSession 远程ip -Credential (Get-Credential)|pscredential

例子
PS C:\Users\Administrator> Enter-PSSession 192.168.3.27 -Credential (Get-Credential)

Enter-PSSession DESKTOP-6G8GBI3 -Credential pscredential

==========================================

 server-manager

server-manager连接远程机器

PS C:\Users\Administrator> Get-Item WSMan:\localhost\Client\TrustedHosts
PS C:\Users\Administrator> Set-Item wsman:\localhost\Client\TrustedHosts "WIN-PPI5UFNN25A"
PS C:\Users\Administrator> Get-Item WSMan:\localhost\Client\TrustedHosts
PS C:\Users\Administrator> cmdkey /add:WIN-PPI5UFNN25A /user:administrator /pass:password1

 

 

winrm命令行工具

The WSMan provider exposes a Windows PowerShell drive with a directory structure that corresponds to a logical grouping of WS-Management configuration settings. These groupings are known as containers.
WSMan: drive

PS C:\Users\fgy> Get-Item wsman:


   WSManConfig:

Type            Name
----            ----
Container       WSMan


PS C:\Users\fgy> Get-Item WSMan:\localhost\

https://docs.microsoft.com/zh-cn/previous-versions/windows/powershell-scripting/hh847813%28v%3dwps.620%29


PS C:\Windows\system32> cd wsman:
PS WSMan:\> ls
PS WSMan:\> cd .\localhost\

Container       Client
Container       Service
Container       Shell
Container       Listener
Container       Plugin
Container       ClientCertificate

 

posted on 2020-02-13 20:19  阳光-源泉  阅读(859)  评论(0编辑  收藏  举报

导航