小编Con*_*eis的帖子

从powershell在新窗口中调用bat文件

我想从 powershell 内的新窗口/独立实例中启动 bat 文件。

bat 文件将从 powershell 获取计算机名,
例如

mybat.bat $thiscomputer
Run Code Online (Sandbox Code Playgroud)

我试过了

start mybat.bat $thiscomputer
start "cmd /c" mybat.bat $thiscomputer
start /k mybat.bat $thiscomputer
start-process mybat.bat $thiscomputer
Run Code Online (Sandbox Code Playgroud)

通常,bat 确实会运行,但保留在 powershell 脚本内。

我需要 powershell 脚本在新窗口中启动 bat 并循环回到开头。

谢谢

孔夫塞斯

windows powershell cmd batch-file

3
推荐指数
1
解决办法
3755
查看次数

从1 csv中删除另一个csv中的行

我在主机/计算机的列表list.csvhost name列.其中一些还没有登录,所以我想删除包含过期计算机记录的所有行.

我可以使用下面的代码获取域中所有未在90天内登录的计算机(ish),但是我想获取计算机列表并将它们进行比较list.csv,从而删除匹配的计算机list.csv.

我已经尝试了一段时间与其他文章Import-CSV等,但不能破解它.

import-module activedirectory  
$domain = "contoso.local"  
$DaysInactive = 90  
$time = (Get-Date).Adddays(-($DaysInactive)) 

# Get all AD computers with lastLogonTimestamp less than our time 
Get-ADComputer -Filter {LastLogonTimeStamp -lt $time} -Properties     LastLogonTimeStamp | 

# Output hostname and lastLogonTimestamp into CSV 
select-object Name | export-csv "C:\users\bicard\Desktop\allComputerslistFromDomainLookup.csv" -notypeinformation
Run Code Online (Sandbox Code Playgroud)

powershell

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

标签 统计

powershell ×2

batch-file ×1

cmd ×1

windows ×1