function funline($strin="hello"){ $num=$strin.length for($i=1;$i -le $num;$i++){$funline = $funline + "="} Write-Host -ForegroundColor Yellow $stri
param($folderPath,$shareName,$maxAllowed=5,$description="BY PowerShell!")if(!$folderPath){ Write-Host "缺少需要共享的目录!";exit}if(!$shareName){ Write-Host "缺少共享名称!";exit}$class="win
$strPath="C:\powershell\test.xls"$objexcel=New-Object -ComObject excel.application$objexcel.Visible=$false$workbook=$objexcel.Workbooks.add()$sheet=$workbook.worksheets.item(1)$x=2$strComputer="."$obj
$strlog="c:\log\applog.txt";$e=$i=$w=0$tpath=Test-Path $strlogif(!$tpath){ New-Item -Path "c:\log" -ItemType dir New-Item -Path $strlog -ItemType file}Get-EventLog -LogName A
Function FunWMI($strShare){ Get-WmiObject win32_share -Filter "type=$strShare"}if(!$args){ Write-Host "You must supply an argument.Try ArgsShare.ps1 ?"}else{ $st
$strPattern="\t"$regex=[regex]$strPattern$text=${c:\hello\text.txt}$mc=$regex.Matches($text)$mc.Count
$strPattern="软件版本"$text=net config workstationswitch -Regex ($text){ $strPattern {Write-Host $switch.current}}
$a=ipconfig /allswitch -Wildcard ($a){ "*DNS 服务器*" {Write-Host $switch.current}}
function funarg(){ switch($args) { "all" { Get-WmiObject -Class win32_logicaldisk} "c" { (Get-WmiObject -Class win32_log
$wmi=Get-WmiObject -Class win32_computersystem write-host "computer " $wmi.name " is:"Switch($wmi.domainrole){ 0{"`t Stand alone workstation"} 1{"`t Member worksta
Get-Service | Sort-Object Status -Descending | ForEach-Object `{ if($_.status -eq "stopped") { Write-Host $_.name $_.status -ForegroundColor Red&nb
[int]$intPing =10; [string]$intNetwork="127.0.0."for($i=1;$i -le $intPing;$i++){ $strQurey="select * from win32_pingstatus where address = '" + $intNetwork + $i + "'" $wmi=Ge
$strClass="usbhub"Get-WmiObject -List | Where-Object {$_.Name -like "*$strClass*"} | ForEach-Object `-Begin{Write-Host "$strclass wmi listing"; Start-Sleep 3} `-process {Get-WmiObject $_.name} `-End {
$strProcess="system"Get-Process | foreach($_.name) {if($_.name -eq $strProcess){Write-Host "$strProcess process is id :"$_.ID}}
$aryComputers="loopback","localhost"Set-Variable -Name intDriveType -Value 3 -Option Constantforeach($strComputer in $aryComputers){ "Hard drives on :"+$strComputer Get
$args="localhost","loopback","127.0.0.1"foreach($i in $args){ $strFile="c:\"+$i+"process.txt" Write-Host "Testing" $i "Please wait...." Get-WmiObject -ComputerNa
if($args){ $type=$args Get-WmiObject win32_share -Filter "type=$type"}else{ Write-Host " Using defaults values,file
Powershell实用脚本
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号