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

  • 相关阅读:
    oracle11g安装客户端检查先决条件失败
    WinForm textbox 只允许输入数字
    Oracle存储过程
    Oracle游标
    Oracle之PL/SQL流程控制
    Oracle 变量
    log4net 使用
    Python Matplotlib 画图显示中文问题
    Oracle 数据迁移到 SQL Server
    C结构体【转】
  • 原文地址:https://www.cnblogs.com/holly/p/1625032.html
Copyright © 2011-2022 走看看