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

  • 相关阅读:
    Spark SQL+day04笔记
    Spark 环境搭建
    海量数据处理 算法总结2
    Scala面试题 看过1
    HTML-table、form表单标签的介绍
    Java-CSS美化网页元素
    Java-BOM与DOM对象
    java-CSS盒子模型、浮动、定位
    java-基础面试题(2)
    Java-io流
  • 原文地址:https://www.cnblogs.com/holly/p/1625032.html
Copyright © 2011-2022 走看看