我希望在 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton11"
android:background="@drawable/image"
android:layout_marginRight="30dp"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton14"
android:layout_below="@+id/imageButton11"
android:align_left="@+id/imageButton11"
android:align_right="@+id/imageButton11"
android:layout_marginTop="10dp"
android:background="@drawable/image"
android:layout_marginRight="30dp"/>
</RelativeLayout>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton12"
android:background="@drawable/image"
android:layout_marginRight="30dp"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton13"
android:background="@drawable/image"
android:layout_marginRight="30dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
中使用this Invoke-ScriptAsync来重启服务器并记录输出。
问题是,Pipe to Out-File是否足以进行日志记录?或者对我正在做的事情有更优雅的解决方案吗?
创建预定作业:
Register-ScheduledJob
现在$trigger = New-JobTrigger -once -at $day
$script = [ScriptBlock]::Create("D:\Scripts\AsyncReboot.ps1 |
Out-File -force d:\logs\$comp-Reboot.log")
Register-ScheduledJob -Name $comp -Credential $user -Trigger $trigger -ScriptBlock $script
将成为D:\Scripts\AsyncReboot.ps1
PowerShell功能,其中包含执行重启的脚本块以及标准Invoke-ScriptAsync
$list = Get-Content d:\scripts\Servers.txt
重新启动脚本,它作为Invoke-ScriptAsync的脚本块运行,并且未创建输出。当我只有$list = gc D:\Scripts\Servers.txt
Reboot-Async -ScriptBlock $AsyncRebootLogging -InputObject `
$list -Timeout 120 -MaxThreads 22 | FT -auto
"Test reboot of $server"