.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Issue in Powershell simple script

Posted By:      Posted Date: October 28, 2010    Points: 0   Category :SharePoint

Hello Guyz,

I am new to powershell ,I wrote a simple function you can find below but ia m unable to excute that function.

function sayhello
   Write-Output  "Hello. Welcome to PowerShell Functions"

I have saved the file (.ps1) and then navigated to the path and excuted the  function

PS C:\Tools> .\Sample.ps1  (I have also tried ..\Sample.ps1)
PS C:\Tools> sayhello
The term 'sayhello' is not recognized as the name of a cmdlet, function, script
 file, or operable program. Check the spelling of the name, or if a path was in
cluded, verify that the path is correct and try again.
At line:1 char:9
+ sayhello <<<<
    + CategoryInfo          : ObjectNotFound: (sayhello:String) [], CommandNot
    + FullyQualifiedErrorId : CommandNotFoundException

Please help me out on this issue.I am sure I am missing something on execution.

View Complete Post

More Related Resource Links

SQL Server Powershell script error!

Hi, I get the following error while trying to execute a powershell script. New-Object : Cannot find type [Microsoft.SQlServer.Management.Sdk.Sfc.SqlStoreConnection]: make sure the assembly containing this type is loaded. I'm trying to implement policies across different sql server instances from a primary instance. The script can be found @ http://blogs.msdn.com/sqlpbm/archive/2008/06/14/running-against-sql-server-2005-and-sql-server-2000.aspx Thanks for your help.

Powershell script that uses Microsoft.SqlServer.Management.Smo.Server need to use Sql Server Autheni

I have written a powershell script that uses Microsoft.SqlServer.Management.Smo.Server.  I have a couple of instances that are on different domains that I must use Sql Server authenication.  I am going to create a report user "sssmorpt".  What is the least a can grant this user to allow me to use Microsoft.SqlServer.Management.Smo.Server to get "$dbsize = $db.size - ($db.logfiles|measure-object -property size -sum).sum / 1024" for all databases in an instances?

PowerShell script to add/edit ContentEditor webpart on SharePoint 2010

Hi all, I'm new to PowerShell scripting with SharePoint. Following are the requirements that were given to me. Can any one direct me in the right direction interms of writing the script and how to save and execute the script? I am aware of Cmdlets. 1. Cycle through all sites in site collection 2. For each site, retrieve all document libraries 3. Look for specific CMV document library name (ie value communication, key business drivers, etc)          o add content editor web part if doesn't exist          o add/update appropriate description based on the document library name Thanks in advance...

Powershell script to copy a list attachment to a file

I have a script that builds a list of items.  I'd like to add the ability to download the list items' attachments to a local directory.  IS this possible?  There are lots of examples of how to add attachments but nothing that can download the attachments.  Any help would be appreciated.

Issue with one of simple query

Hi team, I have a issue in the one of my query select   * from Prod3 where pnumber in (select distinct Policy from prod3_excel) order by pnumber This query gives me 8361 records and there are 8419 records in Prod3 how can i get the remaining records in Prod3 that is 58? select * from Prod3 where pnumber not in (select distinct Policy from prod3_excel) order by pnumber why this is not working? Thanks, Eshwar

Executing PowerShell script for the first time


I am very new to Powershell scripting. I wanted this type of script to be executed for a requirement. Hence I downloaded WindowsServer2003-KB926139-v2-x86-ENU.exe version 1.0 and I referred "Activating features in bulk on the MySite with PowerShell" topic from http://vallery.net/category/sharepoint-2007/

I just copied the script in a notepad, modified the feature ids as per my requirement and saved the file as activate.ps1. Next i opened powershell command prompt and tried to execute the script by typing c:\activate.ps1. But this ended up with following error "The term 'activate.ps1' is not recognized as a cmdlet, function, operable program, or script file". Verify the term and try again.

Can any one help me to run the script. Are there any steps to be performed after installing powershell? I just want the script in the above URL to be executed. Its very urgent.

Thanks in advance,
Ranjana Hegde

Simple WPF ListView Binding Issue


I've uploaded a very simple test project with the issue here: http://www.2shared.com/file/sRVEBh42/KvpTest.html (or here)


The basic problem is, I have a ListView bound to a property on my class. The property is of type ObservableCollection<ObservableKeyValuePair<string, string>>.

I created the ObservableKeyValuePair so I can do two-way binding.


My ListView has 2 columns, Key, and Value. The Value column has a custom DataTemplate which is simply a TextBox, with its Text property setup with a two-way binding (so the user can edit the values of the ObservableCollection<ObservableKeyValuePair<string, string>>.

In my property's setter, I place a breakpoint however it never gets it. The setter of the ObservableKeyValuePair<string, string> is getting hit instead. This seems right, but I need to also propagate that change to the class property my ListView is bound to so I can simply pass the property through to another class and it would contain the changes.

Any ideas how I can achieve this? The sample project is very simple and small if you don't mind downloading it.



How could Transfer a simple object that is created in asp.net to java script code and worked with it


Hi Experts.

I have a simple call in asp.net code behind. There are two variable i, j and some methods in . Like:

Class Test()

{              int i; string str;

                Public getI(int){//.}

Public getJ(int){//.}


Is there any way to have the same class in javascript? I want to create a simple object form this class and initiated its variables and passed it to javascript code and worked with it? How can I do it?


Strange time issue on simple select statement


Hi, I have a strange time out issue on a simple select statement.
This is my select statement:

Select * from DyGeJournal where ord>=4609635 and Fracsec>=31

The ord and Fracsec is the primary key.
When I ask for the actual excecution plan, he is using a an index seek.
It takes more than 1,5 minutes to get a result back.

When I shrink my database, everyting is running as expected, the query above runs in milliseconds.
After a while (2 weeks) it start agian running very slow.

I have the same logic on other tables, but I don't have the problem on those tables.
What can cause this problem?

Java Script Cast Issue


when i Multiply 999999999999999999999.00*1 , then i get 100000000000000000000.00

and when i Multiply 999999999999999.00*1 then i get 999999999999999

Why it is happening

Run powershell script in webpart

I want to run powershell script inside webpart. When user will click Get Users button in webpart then i have to run powershell script and return users list to webpart and display in dropdown.

Regards, Sandip Patil, .Net,Sharepoint Developer www.worldofsharepoint.com

Custom DB Installation Issue While Run the Stored Procedure Script


1. I have created Custom DB Installation by Installar Class
2. I created Stored Procedure Script From DB
3. Copyied Script in sql.txt
4.Created Custom DB Setup and Executed, But I am getting SP script Execution issue, same script is working in QueryAnalyser Execution

Here is My Execution code



Sub ExecuteSql(ByVal DatabaseName As String, ByVal S

Custom DB Installation Issue While Run the Stored Procedure Script


1. I have created Custom DB Installation by Installar Class
2. I created Stored Procedure Script From DB
3. Copyied Script in sql.txt
4.Created Custom DB Setup and Executed, But I am getting SP script Execution issue, same script is working in QueryAnalyser Execution

Here is My Execution code



Sub ExecuteSql(ByVal DatabaseName As String, ByVal S

How to set multiple value for a lookup field with powershell script?


I have a list that has a lookup column and can have multiple values.  I know how to set value to this field with powershell script. I need to know how to set multiple values to this field. 

Also, how can I create this field with powershell script?

Thanks and regards,


Execute PowerShell Script to get Cluster Information from SSIS - Am I crazy?



I created an few scripts that calls cmdlets that gets information from our clusters. The idea is to run the process once and get the information from our clusters into one single place. This is important after outage/patch weekends so we can check the state of our clusters in one single place.

I have never worked with PowerShell scripts before, and I'm doing this after getting inspired by some really clever folks I had the pleasure of seeing at SQL PASS.

I wanted to leverage SSIS so I can take advantage of the the ForEachLoop container and perform the same checks across my 13 clusters.

Have you guys done this before?
Am I on the right path?
Should I use WMI instead or PowerShell?
Any suggestions on how to execute PowerShell scripts from SSIS?
Any other suggestions?

--- Best Regards, Igor Santos - DBA igor.santos@citrix.com

Powershell script to create permission levels & groups and add users


We are trying to setup a Powershell script to create permission levels & groups and add users to groups for a SharePoint site.

We've tried to use the new
PowerShell commandlet for 2010 but it will not add a user to a group unless the user is already defined to the SharePoint site.

Does anyone know how to do this without having to add the users to the site first - or if it can be done - in SP 2010 ?

Thank you..

Issue in SQL server agent job running SSIS package containing a batch script.


I have a package that I have created that runs locally and as package on the server that has a batch script with in it and it run correctly when manually run. But when I create a sql server agent job it runs the job but doesn't execute the package but returns with a successful run. I have setup a proxy account trying to run it with this. I have given the permission to the batch script to the file that the SQL service account. I have tried everything I can think of even setting the package creator to the same name as the service account in the package, and even doing a dtexec command from the SQL job. If I run the dtexec from a cmd prompt the package runs. Need help please thanks.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend