2012-11-02 8 views

cevap

18

Sen yapabilirsiniz:

if ($host.name -eq 'ConsoleHost') # or -notmatch 'ISE' 
{ 
    .. do something .. 
} 
else 
{ 
    .. do something else.. 
} 
3

diğer alternatif ...

Try { 
    Start-Transcript -Path <somepath> | Out-Null 
} 

Catch [System.Management.Automation.PSNotSupportedException] { 
    # The current PowerShell Host doesn't support transcribing 
} 
9

bu oldukça bir süre önce sordu ve zaten cevaplanmış olarak işaretlenmiş biliyor, ama bir yolunu daha:

function Test-IsISE { 
# try...catch accounts for: 
# Set-StrictMode -Version latest 
    try {  
     return $psISE -ne $null; 
    } 
    catch { 
     return $false; 
    } 
} 

$ psISE ISE mevcut:

if (Test-Path variable:global:psISE) 
{ 
... 
} 
: Burada

http://technet.microsoft.com/en-us/library/dd819500.aspx

0
üreten istisnasız $psISE özendirdiği için görünen bir yöntem var
İlgili konular