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上都要执行

目录
相关文章
|
Windows
windows计划任务所遇到的闪退、触发器没有按时执行的坑
1、如图:在设置执行程序或脚本时,请一定要给起始于这个bat脚本的目录路径,否则会遇到执行计划任务闪退,对于网上给的尾行加pause也是心很累。
603 0
windows计划任务所遇到的闪退、触发器没有按时执行的坑
|
数据格式 XML
|
网络安全 数据安全/隐私保护 Windows