小编use*_*239的帖子

如何阻止PowerShell窗口关闭以便我可以看到错误?

我正在创建一个本地PowerShell模块下载程序脚本.模块和脚本保存在网络共享上.使用以下命令调用脚本:

& '\\net\DSFShare\Shared Data\Powershell Modules\Install-MyModuleManager.ps1'
Run Code Online (Sandbox Code Playgroud)

它将脚本复制到标准配置文件模块文件夹,然后从模块文件夹运行Install.ps1. Install.ps1如果需要,自我提升.在高架窗口关闭之前,会弹出一个红色错误但窗口关闭太快,我无法看到错误.如何找出错误是什么?

下载程序脚本使用以下命令调用安装程序:

$installerPath = [IO.Path]::Combine($LocalModulePath, 'Install.ps1')
Write-Host "Installer path: $installerPath"
if (Test-Path $installerPath) {
    Write-Host 'Install.ps1 exists.  Running Install.ps1'
    & $installerPath
}
Run Code Online (Sandbox Code Playgroud)

注意,如果来自PowerShell,我填充$installerPath并使用它调用它& $installerPath,我没有看到错误.

我已经检查了应用程序,系统,Windows PowerShell和安全事件日志,并且没有任何与此相关的错误.

所有脚本都是创建一个事件源.如果要运行它,可以使用:

Remove-EventLog -Source 'My.Module.Manager'
Run Code Online (Sandbox Code Playgroud)

之后,将其删除.这是脚本:

Write-Host "Installing module..."
$eventSource = 'My.Module.Manager'

try {
    $sourceExists = [System.Diagnostics.EventLog]::SourceExists($eventSource)
} catch [Security.SecurityException] {
    Write-Verbose "Caught 'SecurityException': $_.Exception.Message" 
}

if ($sourceExists) {
    Write-Host "...installation complete..." 
} else {

    #region ----- Ensure-ProcessIsElevated -----

    if ($Verbose) {
        $VerbosePreference = …
Run Code Online (Sandbox Code Playgroud)

powershell

41
推荐指数
4
解决办法
9万
查看次数

Powershell - 我应该为Undelete使用什么动词

我正在创建一个PowerShell模块.我使用Remove-blah实现了删除功能.现在我需要实现一个Undelete函数.据我所知,它不在批准的动词列表中.Undelete是否有动词使用约定?如果没有,我应该使用什么?

powershell

2
推荐指数
1
解决办法
490
查看次数

我可以在WPF中的Storyboard/Animation末尾设置不同的属性吗?

当我将其可见性设置为可见时,我想让图像闪烁一定次数.当它完成闪烁时,我希望它能让自己再次崩溃.

这是我正在尝试做的简单版本:

<Image Visibility="Collapsed"
       Margin="0,0,3,0"
       Width="24"
       Source="blah"
       Height="24">
  <Image.Style>
    <Style TargetType="{x:Type Image}">
      <Style.Triggers>
        <Trigger Property="Visibility"
                  Value="Visible">
          <Trigger.EnterActions>
            <BeginStoryboard>
              <Storyboard RepeatBehavior="5x"
                          x:Name="flashingStoryboard">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity"
                                                Duration="0:0:1"
                                                FillBehavior="Stop">
                  <DiscreteDoubleKeyFrame Value="0"
                                          KeyTime="0:0:0" />
                  <DiscreteDoubleKeyFrame Value="1"
                                          KeyTime="0:0:0.5" />
                </DoubleAnimationUsingKeyFrames>
              </Storyboard>
            </BeginStoryboard>
          </Trigger.EnterActions>
        </Trigger>
      </Style.Triggers>
    </Style>
  </Image.Style>
</Image>
Run Code Online (Sandbox Code Playgroud)

我可以在XAML中执行此操作吗?

wpf animation xaml storyboard

0
推荐指数
1
解决办法
954
查看次数

标签 统计

powershell ×2

animation ×1

storyboard ×1

wpf ×1

xaml ×1