- $ConfirmPreference 是用來設定cmdlet執行時是否會向使用者確認是否真的要執行的變數
- 有low,medimu,high三種等級
- 預設是high
- cmdlet在設計時會宣告其為何種等級
- Stop-Process -processname "calc" -Confirm
資料來源:http://blogs.msdn.com/powershell/archive/2006/12/15/confirmpreference.aspx
資料來源:http://blogs.msdn.com/powershell/archive/2006/12/15/confirmpreference.aspx
#利用Outlook.Application之com物件
$objOutLook = new-object -com Outlook.Application;
$objNamespace = $objOutLook.GetNamespace("MAPI");
$voice=New-Object -com "SAPI.SPVoice"
[string]$result=""
if([int](get-date).toString("HH") -ge 12)
{
執行指令
PS C:\> $a=(Get-WmiObject -Class Win32_OperatingSystem).LastBootUpTime
PS C:\> $b = New-TimeSpan $(Get-Date –month $a.substring(4,2) -day $a.substring(6,2) -year $a.substring(0,4) -hour $a.substring(8,2) -minute $a.substring(10,2) ) $(Get-Date)
PS C:\> $b
指令如下
Get-WmiObject -Class Win32_USBHub | where {$_.description -like
"*Mass Storage*"} | format-table DeviceID, Description