Search code examples
powershellscreenshot

How to take screenshot of a complete web-page with powershell?


I want to take snapshot of entire web-page with the help of Powershell. I have a code that can give me screenshot of currently active system window but my powershell currently opens web-pages in background in another Internet Explorer Instance. Is there any way to take the web screenshot with powershell.


Solution

  • A PowerShell tool for taking screenshots of multiple web servers quickly.

    PowerWebShot

    A PowerShell tool for taking screenshots of multiple web servers quickly.

    Requirements

    This tool utilizes Selenium and PhantomJS to screenshot web servers. I've included the phantomjs.exe and Selenium WebDriver.dll in this repository but if you would like to download them directly from their sources they can be found here:

    The phantomjs.exe and WebDriver.dll must be in the current working directory of the PowerWebShot.ps1 script.

    Usage

    PowerWebShot can be used to screenshot a single URL with the -URL option or a list of URL's from a file with the -UrlList option. Each web server will have a thumbnail generated and added to an HTML report at report.html in the output directory.

    First, run powershell.exe and import the script with:

    C:\PS> Import-Module PowerWebShot.ps1
    

    Screenshot a single URL

    This command will take a screenshot of http://www.google.com and add it to a file called report.html in an automatically generated directory with the current date/time as the folder title.

    C:\PS> Invoke-PowerWebShot -URL http://www.google.com
    

    Screenshot a list of URLs and output to a custom directory

    This command will take a screenshot each of the URLs in the file "urllist.txt" and add them to a file called report.html. Each screenshot and the report will be located in a directory called "web-server-screenshot-directory".

    C:\PS> Invoke-PowerWebShot -UrlList urllist.txt -OutputDir web-server-screenshot-directory