powershell 记录

本文介绍了.NET应用程序迁移过程中遇到的调试问题解决方法,并分享了使用PowerShell进行SharePoint操作的具体示例,包括文件上传及服务应用管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

}

 

SharepointPowershell

罗列一些命令:

Get-SPDatabase

 

DatabaseMicrosoft.Office.Server.Administration.ProfileDatabase

DataConnectionFile:Microsoft.Office.InfoPath.Server.Administration.DataConnectionFile

 

Get-SPIisWebServiceApplicationPool

Get-SPServiceApplication

Stop-SPServiceInstance –Identity $id –comfirm:$false

远程调用Powershell前,clientserver要执行:

Enable-PSRemoting

Set-executionPolicy unrestricted/remotesigned

 

如果client端是x64,则务必在powerehll-x86-x64上都要执行

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值