zoukankan      html  css  js  c++  java
  • PowerShell 基础命令

    获取系统日志  Get-EventLog -LogName System -EntryType Error -After 2013-9-18

    查看打开PowerShell的时间  (Get-Process -pid $pid).starttime

    判断今天星期几  (Get-Date).DayOfWeek

    判断某年是否为润年  [datetime]::isleapyear(2013)

      [DateTime]是引用一个日期和时间类型,双冒号(::)在PowerShell中是调用静态方法的意思。IsLeapYear()函数用于判断闰年、平年。参数直接以数字的形式给函数即可。

     查看IPv4地址  foreach($ip in(ipconfig) -like '*IPv4*'){($ip -split ':')[1]}

    还有多少天元旦  ([DateTime]"1/1/2014" -[datetime]::now).days

    关机  1.使用Win32_OperatingSystem类的Win32Shutdown方法 2.使用Stop-Computer 跟 Restart-Computer cmdlet

    $strComputer = "."  
    $OS = Get-WmiObject Win32_OperatingSystem -ComputerName $strComputer  
    $OS.psbase.Scope.Options.EnablePrivileges = $true  
    $OS.win32shutdown(1)  

    获取IP地址  [net.dns]::GetHostAddresses('') | select -ExpandProperty IPAddressToString

    三种方法关进程  Stop-Process -name notepad; Get-Process notepad | Stop-Process; (Get-Process notepad).Kill()

    Get Process commandline information  gwmi Win32_Process -Filter "Name='chrome.exe'" | Select-Object CommandLine  注意这里的规范

    重排  gwmi Win32_Process | Select-Object @{Name="Hello";Expression={$_.name}}

    下载  (New-Object System.Net.WebClient).DownloadFile($source, $destination)

        $source="http://www.xiazai.com/dianying.zip"  $destination="c: emp2.zip"

    查寻磁盘大小   gwmi -query "Select * from Win32_LogicalDisk Where DriveType = '3'"

     查寻主板序列号(下载驱动用)  (gwmi Win32_BaseBoard).SerialNumber  对华硕:(gwmi Win32_BIOS).SerialNumber

    进程按启动时间排序  gwmi Win32_Process | sort-object CreationDate | select-object path

  • 相关阅读:
    毕业3年在北京买房,他是怎么赚钱攒钱的?
    Windows Server 2008 如何在IIS中添加MIME类型
    IIS下无法访问.ini后缀文件
    新的一年,我们如何才能收获满满,不留太多遗憾呢?
    你百分之九十九的问题都是因为懒
    为什么你容许陌生人成功,却无法忍受身边人发达
    堆排序
    计数排序
    直接插入排序
    冒泡排序
  • 原文地址:https://www.cnblogs.com/cnsealine/p/3333880.html
Copyright © 2011-2022 走看看