powershell 记录

the following module was built either with optimizations enabled or without debug information
 solution:
 I have also faced the same problem on migrating the application .net 1.x to 2.0 and i solved by disabling the "Warn if no user code on launch" under the debugging option in the tools menu.
 Tools --> Options --> Debugging --> General --> Enable Just my code (Managed only) --> un check "Warn if no user code on launch"
 
Release build模式无法调试,会直接run 过
 
Powershell使用dll
 password="password"password="password"securePassword = ConvertTo-SecureString passwordAsPlainTextForcepassword−AsPlainText−Forcedomain="domain"
 userName="user"userName="user"credential = new-object Management.Automation.PSCredential((domain+"\"+domain+"\"+userName),securePassword)securePassword)computerName = "sptws-sut02"
 mainUrl="http://"+mainUrl="http://"+computerName
 siteName="test"siteName="test"path="C:\Users\pettest\Desktop"
 webName="HAHAHA"webName="HAHAHA"attachmentName="testAttachmentName2"
 attachmentName=attachmentName=attachmentName + ".txt"
 
ret=invokecommandcomputerret=invoke−command−computercomputerName -Credential credential -scriptblock{  param(  [string]credential -scriptblock{  param(  [string]siteName,
 [string]webName,[string]webName,[string]path,
 [string]attachmentName,[string]attachmentName,[string]mainUrl
 )
 
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null
 

spSites=newobjectMicrosoft.SharePoint.SPSite(spSites=new−objectMicrosoft.SharePoint.SPSite(mainUrl)
 

spWeb=spWeb=spSites.openweb(siteName+"/"+siteName+"/"+webName)
 
attachmentUrl=attachmentUrl=path + "\" + attachmentNameattachmentNamefStream = [System.IO.File]::OpenRead(attachmentUrl)attachmentUrl)byteArray = new-object byte[] fStream.LengthfStream.LengthfStream.Read(byteArray,0,[int]byteArray,0,[int]fStream.Length); 
fStream.close()fStream.close()spWeb.Folders["Shared Documents"].Files.Add(attachmentName,attachmentName,byteArray) 
}-argumentlist siteName,siteName,webName, path,path,attachmentName,mainUrlPowershell使sharepointpowershellmainUrlPowershell使用sharepoint自带的powershellret = invoke-command -computer computerNameCredentialcomputerName−Credentialcredential -scriptblock{
 param(
 )
 
ver=ver=host | select version
 if (ver.Version.Majorgt1)$Host.Runspace.ThreadOptions="ReuseThread"AddPsSnapinMicrosoft.SharePoint.PowerShellSetlocationver.Version.Major−gt1)$Host.Runspace.ThreadOptions="ReuseThread"Add−PsSnapinMicrosoft.SharePoint.PowerShellSet−locationhome
 application=GetSPServiceApplicationname"BusinessDataConnectivity"application=Get−SPServiceApplication−name"BusinessDataConnectivity"guid=application.IDwritehostapplication.IDwrite−hostguid
 return guidPublishSPServiceApplicationguidPublish−SPServiceApplicationguid
 }
 
Sharepoint的Powershell
 罗列一些命令:
 Get-SPDatabase
 
Database:Microsoft.Office.Server.Administration.ProfileDatabase
 DataConnectionFile:Microsoft.Office.InfoPath.Server.Administration.DataConnectionFile
 
Get-SPIisWebServiceApplicationPool
 Get-SPServiceApplication
 Stop-SPServiceInstance –Identity idcomfirm:id–comfirm:false
 远程调用Powershell前,client和server要执行:
 Enable-PSRemoting
 Set-executionPolicy unrestricted/remotesigned
 
如果client端是x64,则务必在powerehll-x86和-x64上都要执行




本文转自轩脉刃博客园博客,原文链接:http://www.cnblogs.com/yjf512/archive/2010/10/29/1864413.html,如需转载请自行联系原作者

上一篇:java编程排序之内置引用类型的排序规则实现,和自定义规则实现+冒泡排序运用


下一篇:【高并发】一个工作了7年的朋友去面试竟然被Thread类虐的体无完肤