Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 使用powershell检查ftp文件夹中的文件_Loops_Powershell_Ftp - Fatal编程技术网

Loops 使用powershell检查ftp文件夹中的文件

Loops 使用powershell检查ftp文件夹中的文件,loops,powershell,ftp,Loops,Powershell,Ftp,我希望使用powershell查看ftp文件夹中是否有特定文件。更具体地说,大约有15个不同的文件夹需要检查特定的文件名。有什么想法吗?有一个PowerShell ftp模块 $DEBUG = 1 # Machines $MachineNames = @("machine1","machine2" ) $MachineIPs = @("192.168.1.1","192.168.1.2" ) # Websites $WebsiteNames = @("website1"

我希望使用powershell查看ftp文件夹中是否有特定文件。更具体地说,大约有15个不同的文件夹需要检查特定的文件名。有什么想法吗?

有一个PowerShell ftp模块

$DEBUG = 1
# Machines
    $MachineNames = @("machine1","machine2" )
    $MachineIPs = @("192.168.1.1","192.168.1.2"  )
# Websites
    $WebsiteNames = @("website1","website2" )
    $WebsiteURLs = @("http://yahoo.com","http://google.com"    )

#====== check websites
$i = 0;
foreach ($WebsiteURL in $WebsiteURLs){
    # First we create the request.
    $HTTP_Request = [System.Net.WebRequest]::Create($WebsiteURL)
    # We then get a response from the site.
    $HTTP_Response = $HTTP_Request.GetResponse()
    # We then get the HTTP code as an integer.
    $HTTP_Status = [int]$HTTP_Response.StatusCode
    #$HTTP_Response
    If ($HTTP_Status -eq 200) { 
        if ($DEBUG -eq 1) {Write-Host "== " $WebsiteNames[$i] " is OK!" }
    }
    Else {
        if ($DEBUG -eq 1) {Write-Host "==Error: "$WebsiteNames[$i] " may be down!" }
        SendEmails $WebsiteNames[$i]
    }
    # Finally, we clean up the http request by closing it.
    $HTTP_Response.Close()
    Clear-Variable HTTP_Response
    $i = $i + 1
}

#====== check IP
$i = 0;
foreach ($MachineIP in $MachineIPs){
    $isValidIP = Test-Connection $MachineIP -Count 1 -Quiet 
    if ($DEBUG -eq 1) {
    $hostn = [System.Net.Dns]::GetHostEntry($MachineIP).HostName
    New-Object -TypeName PSObject -Property @{'Host'=$hostn;'IP'=$MachineIP}
    }
    if (-not($isValidIP)) {
        if ($DEBUG -eq 1) {Write-Host "==Error: " $MachineNames[$i] " ("$MachineIPs[$i]") may be down!" }
        SendEmails $MachineNames[$i]
    }
    $i = $i + 1
}