zoukankan      html  css  js  c++  java
  • Powershell Study, my common command

    Study powershell step by step.

    CMD#01. Retrieve only items in the PSDrive that are not directories.
    GCI C:\ | where {!$_.psiscontainer}


    CMD#02. List all of the WMI Namespace

    $wmi = Get-WmiObject -class __Namespace -namespace root
    $wmi | format-table name
    write-host -foregroundcolor green "There are " $wmi.length `
    " namespaces on this machine `n"

    CMD#03. Browse WMI classes on a computer

    $objLocator = New-Object -ComObject "Wbemscripting.swbemlocator"

    $objWMIService = $objLocator.ConnectServer(".", "\root\cimv2", "", "", "", "", "0")

    $colItems = $objWMIService.SubclassesOf()

    foreach ($objItem In $colItems)
    {
        $objItem.path_.class
    }

    CMD#04. Query with WMI

    $strComputer = "."
    $wmiNS = "root\cimv2"
    $wmiQuery = "select name from win32_share"

    $objWMIServices = get-wmiobject -computer $strComputer -namespace $wmiNS -query $wmiQuery
    $objWMIServices | sort -property name | format-table -property name

    CMD#05. Retrieve a listing of all commands typed during a Windows PowerShell session

    get-history, or h

    CMD#06. select-string, examines all files in the subdirectories of C:\Windows\System32 with the .txt file name extension and searches for the string "Microsoft".

    get-childitem c:\windows\system32\* -include *.txt -recurse | select-string -pattern "Microsoft" -casesensitive

  • 相关阅读:
    进度条
    html5 表单新增事件
    html5 表单的新增type属性
    html5 表单的新增元素
    html5 语义化标签
    jq 手风琴案例
    codeforces 702D D. Road to Post Office(数学)
    codeforces 702C C. Cellular Network(水题)
    codeforces 702B B. Powers of Two(水题)
    codeforces 702A A. Maximum Increase(水题)
  • 原文地址:https://www.cnblogs.com/holly/p/1625032.html
Copyright © 2011-2022 走看看