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,如需转载请自行联系原作者

相关文章
|
Windows
PowerShell添加或修改注册表开机启动项脚本
代码如下: $name = Read-Host "请输入开机启动项的名字(随便起)" $value = Read-Host "请输入开机启动项的值" try{ New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name $name -PropertyType String -Value $value -ErrorAction Stop $tip = "成功添加开机启动项"+$name+"。
2293 0
|
jenkins Shell 持续交付
大坑记录 - shell脚本删除操作
背景 jenkins执行去执行shell命令,其中引用了一些jenkins的变量,如${WORKSPACE}这种,因为每次执行jenkins比较慢,于是想复制脚本出来想本地调试一下,直接复制了脚本过来执行,结果又这么一句 rm -rf ${WORKSPACE}/* 用root去执行,结...
866 0
|
数据格式 XML