Powershell example 3
来源:互联网 发布:linux dns 缓存时间 编辑:程序博客网 时间:2024/05/18 10:56
Blocktest.ps1
$sb = { foreach ($process in $input) { $process.ProcessName }}get-process | &$sbFunctiontest.ps1
$a = "Hello"function foo ($b) { $b.ToUpper() $b.ToLower()}$x = foo $a$x
Script1.ps1
trap { write-host "YIKES!!!" throw $_}script2
Script2.ps1
TrapTest.ps1trap { write-host "In Script2" break}$a = get-content C:/nofile.txt -erroraction stop
function CheckWMI ($computer) { trap { write-host "An error occured: " write-host "ID: " $_.ErrorID write-host "Message: "$_.Exception.Message throw "Couldn't check $computer"}$a = get-wmiobject Win32_OperatingSystem ` -property ServicePackMajorVersion ` -computer $computer -ea stopwrite-host "$computer : " $a.ServicePackMajorVersion}write-host "Service Pack Versions:"CheckWMI("DON-PC")CheckWMI("TESTBED")
TrickyDebugging.ps1$foo = "this is the original text"function f1($str){ "Calling f1..." $str.toUpper()}function f2($value){ "Calling f2... what is value?" $value | get-member "" "Before f1 value is: " + $value "Before f1 foo is: " + $script:foo $script:foo = f1 $value "after f1 value is: " + $value "after f1 foo is: " + $script:foo}"""BEFORE PASS 1, WHAT IS FOO?"$foo | get-member"""PASS 1"f2 $foo"""AFTER PASS 1, WHAT IS FOO?"$foo | get-member"""""PASS 2"f2 $foo"""global value"$foo
DebugTest.ps1
function F1 { param ($n, $a) if (F2($a)) { "$n is old enough to vote" } else { "$n is too young to vote" }}function F2 { param ($var) if ($var -gt 17) { $true } else { $false }}[string]$name = "Joe"[int]$age = 25F1 $name, $age
- Powershell example 3
- Powershell example 1
- Powershell example 2
- Powershell example 4
- Powershell example 5
- Powershell example 6
- PowerShell探秘(3)常用命令
- PowerShell
- PowerShell
- PowerShell
- PowerShell
- PowerShell
- PowerShell
- PowerShell
- powershell
- Powershell
- PowerShell
- Powershell
- TASK
- 今天我写了第一篇博客
- 对话框使用VIEW (转)
- 检测.net环境的C++程序
- 一些鲜为人知的编程事实
- Powershell example 3
- 7000词汇这么背我比较可以接受,连续看20天足以
- c语言条件编译
- Powershell example 4
- 7000词汇这么背我比较可以接受,连续看20天足以
- 一些鲜为人知的编程事实
- 很短,但是会给你打很高分的英语口语集锦
- Powershell example 5
- 状态栏 标题栏 隐藏