zoukankan      html  css  js  c++  java
  • windows管理方式

    windows管理方式演进

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

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

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

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


    PS C:Windowssystem32> get-credential

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

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

    [DESKTOP-6G8GBI3]: PS C:UsersAdministratorDocuments> 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:localhostClientTrustedHosts "*" -Force

    本地命令行下
    如何将计算机添加到受信任主机列表,相当于ssh连接时的警告一样,首次添加,后续不用了
    
    PS C:Windowssystem32> get-item WSMan:localhostClientTrustedHosts
    PS C:Windowssystem32> Set-Item WSMan:localhostClientTrustedHosts -value llc-nb
    
    set-item wsman:localhostClientTrustedHosts -value 192.168.6.23
    PS C:UsersAdministrator
    > Enter-PSSession 位于命令管道位置 1 的 cmdlet Enter-PSSession 请为以下参数提供值: ComputerName: llc-nb [llc-nb]: PS C:UsersAdministratorDocuments>

    PS C:UsersAdministrator> 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:UsersAdministrator> Enter-PSSession 192.168.3.27 -Credential (Get-Credential)

    Enter-PSSession DESKTOP-6G8GBI3 -Credential pscredential

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

     server-manager

    server-manager连接远程机器
    
    PS C:UsersAdministrator> Get-Item WSMan:localhostClientTrustedHosts
    PS C:UsersAdministrator> Set-Item wsman:localhostClientTrustedHosts "WIN-PPI5UFNN25A"
    PS C:UsersAdministrator> Get-Item WSMan:localhostClientTrustedHosts
    PS C:UsersAdministrator> 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:Usersfgy> Get-Item wsman:
    
    
       WSManConfig:
    
    Type            Name
    ----            ----
    Container       WSMan
    
    
    PS C:Usersfgy> Get-Item WSMan:localhost
    
    https://docs.microsoft.com/zh-cn/previous-versions/windows/powershell-scripting/hh847813%28v%3dwps.620%29
    
    
    PS C:Windowssystem32> cd wsman:
    PS WSMan:> ls
    PS WSMan:> cd .localhost
    
    Container       Client
    Container       Service
    Container       Shell
    Container       Listener
    Container       Plugin
    Container       ClientCertificate
  • 相关阅读:
    常用内建函数
    函数作用域
    异常处理语句
    迭代器---待延申扩展
    流程控制语句
    字典
    集合
    数据类型的可变与不可变
    Openstack keystone组件详解
    云计算openstack介绍(001)
  • 原文地址:https://www.cnblogs.com/createyuan/p/12304976.html
Copyright © 2011-2022 走看看