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

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

Executing PowerShell script for the first time

Posted By:      Posted Date: September 21, 2010    Points: 0   Category :SharePoint

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

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...

SQLDataAdapter/SQLDataReader takes lot of time for executing a query

All, I have a webpage with 6 drop down lists. User can start with selecting any drop down list first, and then proceed in any order.  1. Assume when the 1st dropdown is selected first, rest 5 drop downs (except 1st) are filtered/updated based on the selected value in the 1st dropdown. 2. Assume user selects the 4th dropdown second, rest 5 drop downs (except 4th) will be filtered/updated but the condition would be based on both 1st drop down and 4th drop down. But while filtering the first drop down, only the 4th drop down is used as filter (self-filter will be ignored). The code works fine but I see a very bad performance hit in time when the user selects the fourth dropdown after selecting three drop downs. I tried using both SQLDataAdapter and SQLDataReader but neither used to solve the issue. The code takes a lot of time on one line in either of the code (which is highlighted below). When I run the query in SQLServer Mgmt Studio, the query completes in a few seconds.Using SQLDataReader: SqlConnection conn = new SqlConnection(CONNECTION); SqlCommand ObjCmd = new SqlCommand(query, conn); ObjCmd.CommandTimeout = 600; conn.Open(); SqlDataReader daSelTools = ObjCmd.ExecuteReader(); //This line takes a lot of time ddl.Items.Clear(); // Call Read before accessing data. while (daSelTools.Read()) { ddl.Items.Add(new ListItem(String.Format("{0}",daSelTools[0])));

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.

how to check one time java script file download not every session

how to check one time java script file download not every session

error while executing SP more than one time

below the sample table and SP, CREATE TABLE A (ID INT IDENTITY(1,1), SOURCE VARCHAR(5)) ALTER PROCEDURE TEST2 (@PASSEDXML XML) AS BEGIN BEGIN TRY DECLARE @TESTXML XML(test) SET @TESTXML = @PASSEDXML PRINT 'A' END TRY BEGIN CATCH INSERT INTO A (SOURCE) VALUES ('A') END CATCH END GO and the XML schema "test" is below, CREATE XML SCHEMA COLLECTION [dbo].[test] AS N' <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType name="GroupOrder"> <xs:restriction base="xs:string"> <xs:pattern value="[1-9]"/> </xs:restriction> </xs:simpleType> <xs:element name="PDI_Approval_MetaData"> <xs:complexType> <xs:sequence> <xs:element name="TranDetails"> <xs:complexType> <xs:sequence> <xs:element name="GroupOrder"> <xs:complexType> <xs:attribute name="Value" type="GroupOrder" use="optional" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>' Now, while I executing below SP (that goes to catch

Service is executing code after time out.

Hi All,  I am using IsOne way and nettcp binding in mu WCF. [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single,ConcurrencyMode=ConcurrencyMode.Multiple)]   public class FlexiAsyncServer : IAsyncInterface   {       public void OneWayRequest()         {              for (int i = 0; i <= 5000; i++)                 {                     DbCommand cmd = dbAsync.GetSqlStringCommand("insert into  JOB_DEFNN (JOB_NM,JOB_STAT_CATG_ID,JOB_GRP_ID) values('"+i.ToString()+"',1,101)");                     dbAsync.ExecuteNonQuery(cmd);                 }           } } In Service side before inserting this 5000 records into database i am getting time out error in client side. But though i got error the records are being inserted until it complets 5000. My question is why the service side execution is not stopping a

problem executing sql script (oracle)



i have a problem in executing an sql script

            Cmd.CommandType = CommandType.Text
            Cmd.Connection = Cn

            objReader = New System.IO.StreamReader("Script.sql")
            Cmd.CommandText = objReader.ReadToEnd

the error was  : "invalid caracter"

please help .


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

Issue in Powershell simple script


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.

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..

Set Connection of OLE DB Source component at run-time in a script



Is it possible to set the Connection property of an OLE DB Source component at run-time using a script task? The Connection Manager exists at design time but based on different development/production databases, I need to set which connection manager should be used for the OLE DB source at rum time. If possible, how do I accomplish this?

(Visual Studio 2005)


Round off time to the nearest minute

How would you round this up to the nearest minute? There isn't a built in function to do this so you have to use a little bit of maths to get there. There are 60 seconds in a minute. We already have 38 seconds on the clock. So we need to add on 60 - 38 = 22 more seconds.

Performance Tests: Precise Run Time Measurements with System.Diagnostics.Stopwatch

Everybody who does performance optimization stumbles sooner or later over the Stopwatch class in the System.Diagnostics namespace. And everybody has noticed that the measurements of the same function on the same computer can differ 25% -30% in run time. This article shows how single threaded test programs must be designed to get an accuracy of 0.1% - 0.2% out of the Stopwatch class. With this accuracy, algorithms can be tested and compared.
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