检查远程计算机桌面上的文件
Checking for file on remote computer's desktops
我正在尝试 运行 一个循环,该循环检查计算机列表中是否有桌面上的特定访问数据库。我在检查 Users\Default 等路径时可以使用它,但实际上我需要它来检查当前登录用户的 桌面 。这可能吗,或者我需要一个特定用户名的列表来与计算机名称的 .txt 一起使用吗?
$computers=Get-Content C:\Users\zrasner\Documents\project_files\powershell_computernames\computernames.txt
foreach ($computer in $computers) {
$path = Test-Path "\$computer\c$\Users\Default\VAST.accdb\"
If ($path -eq $true) { Write-Host "($computer) VAST is present in Default Users Folder"}
If ($path -eq $False) { Write-Host "($computer)VAST File Not Found"}
}
同样,我想将检查目标更改为相关远程计算机的桌面。
下面代码中的第一行 $user
获取用户名。 $user = ($user).Split('\')[-1]
行由反斜杠分割,returns 分割的最后一部分。这意味着它将从 domain\username 或用户名中捕获用户名。
$computers=Get-Content C:\Users\zrasner\Documents\project_files\powershell_computernames\computernames.txt
foreach ($computer in $computers) {
$path = $false
$user = Get-WmiObject –ComputerName $computer –Class Win32_ComputerSystem | Select-Object -ExpandProperty UserName
$user = ($user).Split('\')[-1]
$path = Test-Path "\$computer\c$\Users\Default\VAST.accdb"
If ($path) { Write-Host "($computer) VAST is present in Default Users Folder"}
$path = Test-Path "\$computer\c$\Users$user\VAST.accdb"
If ($path) { Write-Host "($computer) VAST is present in currently logged on user ($user)'s Folder"}
If ($path -eq $False) { Write-Host "($computer)VAST File Not Found"}
}
我正在尝试 运行 一个循环,该循环检查计算机列表中是否有桌面上的特定访问数据库。我在检查 Users\Default 等路径时可以使用它,但实际上我需要它来检查当前登录用户的 桌面 。这可能吗,或者我需要一个特定用户名的列表来与计算机名称的 .txt 一起使用吗?
$computers=Get-Content C:\Users\zrasner\Documents\project_files\powershell_computernames\computernames.txt
foreach ($computer in $computers) {
$path = Test-Path "\$computer\c$\Users\Default\VAST.accdb\"
If ($path -eq $true) { Write-Host "($computer) VAST is present in Default Users Folder"}
If ($path -eq $False) { Write-Host "($computer)VAST File Not Found"}
}
同样,我想将检查目标更改为相关远程计算机的桌面。
下面代码中的第一行 $user
获取用户名。 $user = ($user).Split('\')[-1]
行由反斜杠分割,returns 分割的最后一部分。这意味着它将从 domain\username 或用户名中捕获用户名。
$computers=Get-Content C:\Users\zrasner\Documents\project_files\powershell_computernames\computernames.txt
foreach ($computer in $computers) {
$path = $false
$user = Get-WmiObject –ComputerName $computer –Class Win32_ComputerSystem | Select-Object -ExpandProperty UserName
$user = ($user).Split('\')[-1]
$path = Test-Path "\$computer\c$\Users\Default\VAST.accdb"
If ($path) { Write-Host "($computer) VAST is present in Default Users Folder"}
$path = Test-Path "\$computer\c$\Users$user\VAST.accdb"
If ($path) { Write-Host "($computer) VAST is present in currently logged on user ($user)'s Folder"}
If ($path -eq $False) { Write-Host "($computer)VAST File Not Found"}
}