:::: MENU ::::

Posts Categorized / PowerShell

  • Aug 27 / 2013
  • 0
dbDigger, PowerShell, SQL Server Agent scheduled Jobs, SQL Server Error messages

Error message while using PowerShell in scheduled job

I was required to call PowerShell script from SQL Server scheduled job. Following was the command to access and run the PS script saved on disk.
powershell -command “& ‘D:PscriptsTransfer.ps1’ ”

This command syntax may be saved in batch file or directly run from cmd. However surprisingly i was facing following error message in job history. It is notable that job status was successful however error messages were logged there in job history.

A job step received an error at line 1 in a PowerShell script. The corresponding line is ‘powershell -command “&’%'”‘. Correct the script and reschedule the job. The error information returned by PowerShell is:

Apparently it was pointing towards syntax used in the command however i did not find any issue in the command. It was working fine outside the SQL Server scheduled job environment. Also i did not get any help through googling. However i analyzed the issue in terms of permissions that we mostly face in scheduled job environment.

So first step was to create a proxy account. I will cover the topic of creating proxy account for SQL Server agent job in a separate post. After creating the proxy account i used it in scheduled job and ran the job to test.
The idea worked and job executed successfully.
  • Aug 23 / 2013
  • 0
dbDigger, PowerShell, SQL Server Error messages, System Administration

File %.ps1 cannot be loaded because the execution of scripts is disabled on this system.

Now a days i am working on a powershell task. This morning i prepared a basic powershell script and run it to see that how close are the results. I called the powershell script from cmd so that any errors may be seen if generated. To my surprise it generated a different type of error pointing to some configuration

Error while executing power shell script

In a more readable text form the errror statement is

File %.ps1 cannot be loaded because the execution of scripts  is disabled on this system. Please see “get-help about_signing” for more details.

I looked for the solution and implemented it to allow PS scripts run on my stystem. Following is the brief solution that i implemented.

Step1: Check current system setting for scripts

launch powershell and execute Get-ExecutionPolicy 


It shows that current script execution is restricted.

Step2: Change the script execution policy

Now we have to change the script execution policy. We have three other options to set.

  • RemoteSigned: You can run your own scripts but downloaded scripts will have to be signed in order to run on the system.
  • AllSigned: Your own or dowloaded scripts all should be signed to run.
  • Unrestricted: Remote or your own scripts may be run without signing check.

So you may choose an appropriate option and run one of the following command according to choice

  • Set-ExecutionPolicy RemoteSigned
  • Set-ExecutionPolicy AllSigned
  • Set-ExecutionPolicy UnRestricted

Step 3: Verify

You may verify the new policy implementation by repeating step 1. This time you will get the new policy name instead of restricted policy.

After implementing this solution i proceeded with my original tasks by writing and executing the PS scripts successfully. Hope same for you.

  • Jan 16 / 2011
  • 0
dbDigger, PowerShell

Tab Completion feature of PowerShell

PowerShell provides a great feature known as Tab Completion. It is very helpful to deal with large number of cmdlets used in PS. Usage of Tab Completion feature is very simple.

  • Type the primary part of cmdlet that you are confirmed about.
  • Press tab key and with each press it would display alphabetically, all the cmdlets that start with your typed primary characters
  • To get the cmdlets alphabetically in descending order press Shift+Tab
  • So Shift+Tab and Tab may be used to travel among the matched cmdlets list
  • Jan 15 / 2011
  • 1
dbDigger, Deployment, PowerShell

Setup cannot proceed. windows management framework core is already installed on your system

Few weeks back, I uninstalled PowerShell from Windows Server 2003 due to some requirement and continued to use PowerShell on my lpatop (Windows 7). Today i was again required to install PowerShell 2.0 on Windows Server 2003. I downloaded the PowerShell for Windows Server 2003. As setup file was executed following error frame was generated

windows management framework core is already installed

The error statement was as under

Setup cannot proceed. Windows management framework core is already installed on your system.

If you also get this error message then Go to “Add Remove Program” window in control panel and make sure that check box for Show Updates is checked. There you can find the installed Windows Management Framework. Remove this update and you can now proceed with installation process of PowerShell 2.0.
Such issue may also be there when you are trying to upgrade from PowerShell 1.0 to PowerShell 2.0.

Consult us to explore the Databases. Contact us