Sunday, 8 May 2016

Using Task Scheduler to automate PowerShell Scripts

Today I am Providing the way to run PowerShell scripts using Windows Scheduler.

Windows Task Scheduler allows you to schedule PowerShell scripts to accomplish a wide variety of commands on the scheduled time that best fits your needs.


1.    Open Task Scheduler and create a new task. Give it a Name and set your security options as per your requiredments.  Check "Run with highest privileges" as our most scripts need to run as admin.  If you want this script to run without logging in to system, enable the 'Run whether user is logged on or not' radio button.


2.    Click on the Triggers tab and set your schedule or event that will trigger the running of your PowerShell script.        


3.    Click on the Actions tab and click on New.

Action: Start a program

Program/script: Powershell.exe

You don't need to put a path as it should already be on your system.

4.    First you need to set the ExecutionPolicy. You have two options here, you can set the ExecutionPolicy on the machine or you can do it on a per-script basis.

To set the execution policy globally, you can issue this command from within PowerShell:

Set-ExecutionPolicy Unrestricted

      However, here we want to set the execution policy on a per script basis and open up security for us to run the script. This security policy will only be in effect for the script we are running and not compromise security otherwise.

That means we use the following Argument:

-ExecutionPolicy Bypass -File “Your Script Path”


Now Action Windows Should look like this.
                 
5.  You can provide conditions and Settings if you need or any requirement.
6. Save and Test

Now you script will run on you selected time or on given interval.

Thursday, 7 April 2016

Power Shell Scripts

In This blog you will found use full Power Shell Scripts

  1. Using Task Scheduler to automate PowerShell Scripts
  2. Safely Install/Uninstall/Update a SharePoint Solution
  3. Get List of all SharePoint's Web Applications, Site Collections, Sub sites, List/Library
  4. Download All items from SharePoint in Local Farm
  5. Download Content using filter on given Column in Given site and list
  6. Get the list of All Users and Groups of a given site
  7. Get the list of All Users and Groups of Local Farm
  8. Download All solutions (wsp files) in SharePoint
  9. Set Lock State in a Site Collection (Site is in Read Only Mode Solved)
  10. Enable/Disable Save Site as Template Option
  11. Enable/Disable Delete and Save List/Library as template option
  12. Create List/Library
  13. Clear Cache of all severs in one go
  14. Granting permissions to users and groups on item level
  15. Creating a normal or host named Site Collection on given database
  16. Creating a new Content database on a given web application
  17. Modify the Site url of content type hub in Managed Metadata service application
  18. Delete Site/Site collection in bulk using a csv file
  19. View Threshold limit issue in List/Library
  20. Enable Developer Dashboard
  21. Reset BLOB Cache 
  22. Find a given webpart in the given site collection
  23. Map User profile property for Ad Synchronization