如果尝试在ineracvie powershell中执行某些操作,是否有可能捕获特定的错误?我的意思是:
powershell.exe
PS C:>_
PS C:>fuu
fuu: this is not a cmdlet .... BLA BLA BLA
+ ~~~
+ CategoryInfo : ObjectNotFound: (fuu:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
这是惰性powershell的正
我是在码头的新手,我创建了下面的码头文件,它运行良好。
# escape=`
FROM microsoft/aspnet:4.6.2 as base
SHELL ["powershell"]
ENV ENABLE_IIS_CONSOLE_LOGGING=1
RUN Import-Module WebAdministration; `
Import-Module ServerManager -Force; `
但一旦我在上面加了一个评论
# This is a comment line
# escape=`
FROM microsoft/aspnet:4.6.2 as base
在使用Get命令在中使用多行过滤器表达式时,使用回勾(严肃重音)是有困难的。具体来说,我正在Windows7上测试PowerShell 2.0。
一个工作示例(过滤器都在一行上):
Get-ADUser -Filter {Name -like "Smith*" -and Enabled -eq $True}
# This works as expected, a list of matching objects is returned on pipeline
一个坏了的例子(过滤器被分割成多行):
Get-ADUser -Filter {Name -like "Smit
我想将.NET对象强制转换为另一种.NET类型,但是:
目标.NET类型(类)存储在变量中。
我不想使用-as PowerShell操作符
我使用的是复杂的非原始类型。
你是如何做到这一点的?
例如,这是"PowerShell“的方法,但我不想使用-as
$TargetType = [System.String]; # The type I want to cast to
1 -as $TargetType; # Cast object as $TargetType
不幸的是,这是行不通的:
$TargetType = [System.Str