我已经创build了以下脚本:
#This scripts finds if 2 LST files were created today. #What date are we in $today = Get-Date #Are there two lst files? $Lst = @(Get-ChildItem 'PATH' -recurse -include @("*.lst") | Where-Object { $_.CreationTime -gt (Get-Date).Date }) if ($Lst.length -eq 2) { $LstStatus = "Files OK" $filename = (Get-ChildItem 'PATH' -recurse -include @("*.lst") | Where-Object { $_.CreationTime -gt (Get-Date).Date } | Select-Object Name) } else { $LstStatus = "LST ERROR" } #What do I want in the file $output = @(Write-Host -NoNewline @($today.ToShortDateString()) @($filename.name) $LstStatus) $output | Out-File PATHlst_check.txt`
$output有我需要的信息和lst_check.txt被创build,但它是空的。
我错过了什么? 有没有其他的命令我应该更换Write-Host ?
当没有login到服务器时,Get-Service脚本不起作用
从远程机器(不是容器主机)build立PSSession到Windows docker容器
为什么从Git命令的长时间结果会导致我的PowerShell提示失败?
Get-Childitem:非法字符path错误
在powershell中合并2个csv文件
使用Topshelf安装后,无法看到我的服务
如何使用PowerShell显示连接的USB设备与驱动器号
如何更改PowerShell脚本中哈希表列的标题
删除WinRM日志时,为什么Windows客户端调配失败?
如何查找签出的文件
Write-Host直接写你的输出到主机应用程序,在你的情况下可能是控制台。
$output = "$($today.ToShortDateString()) $($filename.name) $LstStatus" Write-Host "This is the output: $output" $output | Out-File PATHlst_check.txt
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。