小编LaP*_*Phi的帖子

VisualStudio 2010 - PowerShell加载项?

是否有适用于VisualStudio 2010的PowerShell Add-Inn?我只找到VS 2005和2008的VS Command Shell加载项(2007年加载项)

powershell add-in visual-studio-2010 powershell-2.0 visual-studio

8
推荐指数
1
解决办法
8730
查看次数

SharePoint PowerShell站点权限

我想在站点上授予域用户SharePoint权限.SharePoint中的peoplepicker找到了用户,我可以将浏览器中的用户添加到站点.但是当我使用PowerShell时,用户不在SharePoint GUI的权限列表中.

PS: New-SPUser -UserAlias "test\TestUser2" -PermissionLevel Contribute -web http://test.sharepoint.de/site/page

PS:
UserLogin            DisplayName         
---------            -----------         
TEST\testuser2       TestUser2  
Run Code Online (Sandbox Code Playgroud)

也没工作:

Get-SPWeb "http://test.sharepoint.de/site/page" | New-SPUser –UserAlias "test\TestUser2" -PermissionLevel Contribute
Run Code Online (Sandbox Code Playgroud)

powershell sharepoint

7
推荐指数
1
解决办法
1万
查看次数

PowerShell - 异常处理

我正在寻找在PowerShell中处理异常的最佳方法.在以下示例中,我想创建一个新的SharePoint Web并删除旧的SharePoint Web.当New-SPWeb失败时,脚本必须结束.我认为try/catch是最好的方法,因为"if"语句只检查$ a是否存在.处理异常还有其他选择吗?

使用"if"语句处理异常:

$a = New-SPWeb http://newspweb
if($a -eq $null)
{
Write-Error "Error!"
Exit
}
Write-Host "No Error!"
Remove-SPWeb http://oldspweb
Run Code Online (Sandbox Code Playgroud)

使用try/catch:

try
{
$a = New-SPWeb http://newspweb
}
catch
{
Write-Error "Error!"
Exit
}
Write-Host "No Error!"
Remove-SPWeb http://oldspweb
Run Code Online (Sandbox Code Playgroud)

powershell powershell-2.0

7
推荐指数
2
解决办法
2万
查看次数

WebDAV - 请求"在文件夹中显示文件"?

我想从WebDAV共享下载所有*.txt文件.是否有请求/方法来获取此文件夹中的文件列表?

我是WebDAV的新用户,在w3.org WebDAV方法定义中我没有找到这些信息. http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3

webdav http-1.1

7
推荐指数
1
解决办法
2万
查看次数

PowerShell - 枚举集合并更改集合

如何修复此脚本?

是的,我在foreach循环中更改了集合,这就是导致此错误的原因.

通过集合枚举时发生错误:集合已被修改; 枚举操作可能无法执行..在C:\ Users\user\Documents\PowerShell\ChangeAllListsV2.ps1:47 char:20 + foreach <<<<($ list in $ webLists)+ CategoryInfo:InvalidOperation:(Microsoft.Share. ..on + SPEnumerator:SPEnumerator)[],RuntimeException + FullyQualifiedErrorId:BadEnumeration

#Script change in all lists the required field property "testfield" to false


#Part 0 - Configuration

$urlWebApp = "http://dev.sharepoint.com"
$countFound = 0
$countList = 0
$countFoundAndChange = 0

#Part 1 - PreScript  

$snapin = Get-PSSnapin | Where-Object {$_.Name -eq "Microsoft.SharePoint.Powershell"}

if ($snapin -eq $null)

{
    Write-Host “Loading SharePoint Powershell”
    Add-PSSnapin Microsoft.SharePoint.Powershell
}

#Part 2 - Script

$webApp = Get-SPWebApplication $urlWebApp

#$webApp …
Run Code Online (Sandbox Code Playgroud)

powershell foreach sharepoint

7
推荐指数
2
解决办法
2万
查看次数

PowerShell - IE对象,设置值错误

我想用PowerShell创建一个脚本来检查航班状态.但是我不可能设置文本框值.

我该如何解决?先感谢您!

错误:在此对象上找不到属性"值"; 确保它存在且可设置.

码:

#Flight Number (Only Lufthansa)
#For example flight number
[string]$flightNumber = "LH 3102"

$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://www.lufthansa.com/de/de/Ankunft-und-Abflug")
$ie.visible = $true
sleep 5
#while ($ie.busy) {sleep -milliseconds 50}
while($ie.ReadyState -ne 4) {start-sleep -m 100}     

$ie.document.getElementsByName("flightNumber").value = $flightNumber
#Error
$ie.document.getElementsByName("flightNumber").IHTMLInputTextElement_value = $flightNumber
#Error
$ie.document.getElementsByName("flightNumber").IHTMLInputElement_value = $flightNumber
#Error
Run Code Online (Sandbox Code Playgroud)

powershell internet-explorer

6
推荐指数
1
解决办法
1万
查看次数

WMI查询 - CPU LoadPercentage

我正在寻找一种更好的方法来使用来自多个系统的WMI来获得CPU负载百分比(意味着不同的CPU等).我的代码正在运行,但我认为有一种更好的方法来克服所有CPU使用率百分比.

有任何想法吗?

先感谢您!

SelectQuery queryCpuUsage = new SelectQuery("SELECT * FROM Win32_Processor");
ManagementObjectSearcher cpuUsage = new ManagementObjectSearcher(scope, queryCpuUsage);                                       
ManagementObjectCollection cpuUsageCollection = cpuUsage.Get();                                                       

foreach (ManagementObject queryObj in cpuUsageCollection)
{                                           
iCPU++;
calcCPU = Convert.ToInt32(queryObj["LoadPercentage"]);
perCPU = perCPU + calcCPU;
}

perCPU = perCPU / iCPU;

cpuUsageCollection.Dispose();

Console.WriteLine("LoadPercentage CPU: {0}", perCPU);
Run Code Online (Sandbox Code Playgroud)

wmi wmi-query

6
推荐指数
1
解决办法
1万
查看次数

从Com Object获取进程ID

可以从这个新的Com对象($ ie)获取进程ID吗?

$ie=New-Object -comobject InternetExplorer.Application  
$ie.visible=$true  
$ie.Navigate("www.stackoverflow.com")
Run Code Online (Sandbox Code Playgroud)

powershell process comobject

5
推荐指数
1
解决办法
7582
查看次数

SharePoint 2010 - 更改SiteCollection URL

是否有一种简单的方法(如PowerShell命令)从SiteCollection更改URL?

或者是导出SiteCollection的唯一方法 - >删除SiteCollection(因为GUID) - >导入SiteCollection?

powershell sharepoint powershell-2.0 sharepoint-2010

5
推荐指数
2
解决办法
2万
查看次数

PowerShell - X509Certificates.X509Store获得所有证书?

我想从我的系统获得所有证书.所以我使用了System.Security.Cryptography.X509Certificates class. 当我删除()之后X509Store我获得了与我输入相同的结果"My"

查看所有证书的正确成员名称是什么?有可能的?

MSDN StoreName枚举

$store=new-object System.Security.Cryptography.X509Certificates.X509Store("CA")
# Put in CA, My, root etc.
$store.open("ReadOnly")
$store.Certificates
$store.Certificates.count 
Run Code Online (Sandbox Code Playgroud)

.net c# powershell

4
推荐指数
1
解决办法
5398
查看次数