Advertisement
Yunga

NasaAPOD.ps1

Apr 23rd, 2015
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Automatically set your wallpaper to NASA’s picture of the day
  2. # http://ps1tips.com/post/117087166929/automatically-set-your-wallpaper-to-nasas-picture
  3. # The first step in order to fetch NASA’s Astronomy Image of the Day is to have an API key. You can get one from https://data.nasa.gov/developer although the DEMO key below will work for now.
  4.  
  5. # Let’s make a call to the API endpoint and parse the JSON data:
  6. $a = Invoke-WebRequest -Uri https://api.data.gov/nasa/planetary/apod?api_key=DEMO_KEY | ConvertFrom-Json
  7.  
  8. # Now that our variable contains a URL and date, we can select a path where to save the image, and then download it:
  9. $path = "$($env:temp)\$($a.date).jpg"
  10. Invoke-WebRequest -Uri $a.url -OutFile $path
  11.  
  12. # Finally, we change the Registry value and reload user settings to set the wallpaper:
  13. Set-ItemProperty -path "HKCU:\Control Panel\Desktop\" -name wallpaper -value $path
  14. rundll32.exe user32.dll, UpdatePerUserSystemParameters
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement