powershell 记录
2010-10-29 13:58 轩脉刃 阅读(530) 评论(2) 编辑 收藏 举报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"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$domain="domain"
$userName="user"
$credential = new-object Management.Automation.PSCredential(($domain+"\"+$userName),$securePassword)
$computerName = "sptws-sut02"
$mainUrl = "http://" + $computerName
$siteName = "test"
$path="C:\Users\pettest\Desktop"
$webName="HAHAHA"
$attachmentName="testAttachmentName2"
$attachmentName = $attachmentName + ".txt"
$ret = invoke-command -computer $computerName -Credential $credential -scriptblock{
param(
[string]$siteName,
[string]$webName,
[string]$path,
[string]$attachmentName,
[string]$mainUrl
)
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null
$spSites = new-object Microsoft.SharePoint.SPSite($mainUrl)
$spWeb = $spSites.openweb($siteName +"/"+ $webName)
$attachmentUrl = $path + "\" + $attachmentName
$fStream = [System.IO.File]::OpenRead($attachmentUrl)
$byteArray = new-object byte[] $fStream.Length
$fStream.Read($byteArray, 0, [int]$fStream.Length);
$fStream.close()
$spWeb.Folders["Shared Documents"].Files.Add($attachmentName, $byteArray)
}-argumentlist $siteName, $webName, $path,$attachmentName,$mainUrl
Powershell使用sharepoint自带的powershell
$ret = invoke-command -computer $computerName -Credential $credential -scriptblock{
param(
)
$ver = $host | select version
if ($ver.Version.Major -gt 1)
{$Host.Runspace.ThreadOptions = "ReuseThread"}
Add-PsSnapin Microsoft.SharePoint.PowerShell
Set-location $home
$application = Get-SPServiceApplication -name "Business Data Connectivity"
$guid=$application.ID
write-host $guid
return $guid
Publish-SPServiceApplication $guid
}
Sharepoint的Powershell
罗列一些命令:
Get-SPDatabase
Database:Microsoft.Office.Server.Administration.ProfileDatabase
DataConnectionFile:Microsoft.Office.InfoPath.Server.Administration.DataConnectionFile
Get-SPIisWebServiceApplicationPool
Get-SPServiceApplication
Stop-SPServiceInstance –Identity $id –comfirm:$false
远程调用Powershell前,client和server要执行:
Enable-PSRemoting
Set-executionPolicy unrestricted/remotesigned
如果client端是x64,则务必在powerehll-x86和-x64上都要执行
实时了解作者更多技术文章,技术心得,请关注微信公众号“轩脉刃的刀光剑影”
本文基于署名-非商业性使用 3.0许可协议发布,欢迎转载,演绎,但是必须保留本文的署名叶剑峰(包含链接http://www.cnblogs.com/yjf512/),且不得用于商业目的。如您有任何疑问或者授权方面的协商,请与我联系。