Skip to content

Instantly share code, notes, and snippets.

@Areso
Created April 25, 2018 06:56
Show Gist options
  • Save Areso/ff6db99fa733f1644d0095cd7c8f171c to your computer and use it in GitHub Desktop.
Save Areso/ff6db99fa733f1644d0095cd7c8f171c to your computer and use it in GitHub Desktop.
Invoke-Command -ComputerName Server01, Server02 -ScriptBlock {Get-UICulture}
Invoke-Command -ComputerName Server01, Server02 -FilePath c:\Scripts\DiskCollect.ps1
Enter-PSSession Server01
Exit-PSSession
@Areso
Copy link
Author

Areso commented Apr 25, 2018

$hostnames = Get-Content "C:\hostnames.txt"
$searchtext = "imaging completed"

foreach ($hostname in $hostnames)
{
$file = "\$hostname\C$\GhostImage.log"

if (Test-Path $file)
{
    if (Get-Content $file | Select-String $searchtext -quiet)
    {
        Write-Host "$hostname: Imaging Completed"
    }
    else
    {
        Write-Host "$hostname: Imaging not completed"
    }
}
else
{
    Write-Host "$hostname: canot read file: $file"
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment