标签: powershell

PowerShell中的权限错误

我是PowerShell的新手.当试图编写一个删除文件夹内容的简单脚本,然后用从不同文件夹复制的文件填充它时,我总是收到PermissionDenied错误.

细节:

+ remove-item <<<<  D:\path\* -recurse
    + CategoryInfo : PermissionDenied: (save.gif:FileInfo) [Remove-Item], IOException
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
Run Code Online (Sandbox Code Playgroud)

问题出在哪儿?我可以通过资源管理器操作这两个文件夹.从脚本文件和shell(使用Windows PowerShell ISE)运行时都会发生错误.ISE流程在我的帐户下运行.我正在运行Windows 7 Professional并且是本地管理员.

编辑: 在理查德的建议之后,我尝试了详细模式(似乎没有效果).

PS Z:\> $error[0] | fl * -force

PSMessageDetails      : 
Exception             : System.IO.IOException: Not Enough permission to perform operation.
TargetObject          : D:\path\file.txt
CategoryInfo          : PermissionDenied: (D:\path\file.txt:FileInfo) [Remove-Item], IOException
FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
ErrorDetails          : Cannot remove item D:\path\file.txt: Not Enough permission to perform operation.
InvocationInfo        : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {0, 1}
Run Code Online (Sandbox Code Playgroud)

我没有看到任何有用的东西(但感谢提示).

编辑2: 好的,这是脚本来源:

remove-item …
Run Code Online (Sandbox Code Playgroud)

powershell

37
推荐指数
3
解决办法
8万
查看次数

如何在PowerShell中使用HTTP GET?

可能重复:
获取$ webclient.downloadstring以写入Powershell Powershell http 文本中的文本文件,
其中包含.cer for auth

我有一个SMS系统,使我能够从HTTP GET请求发送SMS:

http://smsserver/SNSManager/msgSend.jsp?uid&to=smartsms:*+001XXXXXX&msg="text of the message"&encoding=windows-1255
Run Code Online (Sandbox Code Playgroud)

我想在PowerShell中输入文本的详细信息,然后浏览此URL.我该怎么做?

powershell http http-get

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

Visual Studio中的Powershell

有谁知道我可以在Visual Studio中运行PowerShell的方法.

我的意思是,在工具窗口中有一个交互式的PowerShell提示符?

善良,

担

powershell extensibility visual-studio-2008

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

Enter-PSSession在我的Powershell脚本中不起作用

当我从脚本运行下面的行时,文件最终会在我的本地计算机上创建.

$cred = Get-Credential domain\DanTest
Enter-PSSession -computerName xsappb01 -credential $cred

New-Item -type file c:\temp\blahxsappk02.txt

exit-pssession
Run Code Online (Sandbox Code Playgroud)

当我从powershell控制台单独运行每一行时,将正确创建远程会话,并在远程计算机上创建该文件.有什么想法吗?时间问题是脚本也许吗?

powershell powershell-remoting

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

Windows批处理脚本中的文件/文件夹选择器对话框

通常,要求用户向批处理脚本提供文件名是一件混乱的事情,不需要拼写错误,带有空格的路径周围的引号等等.不幸的是,用户并不知道准确性.在直到运行时才知道输入文件位置的情况下,使用GUI进行文件选择输入可降低用户错误的可能性.

有没有办法File... Open从Windows批处理脚本调用样式gui文件选择器或文件夹选择器?

如果脚本用户安装了PowerShell或.NET,则可以.请参阅以下答案.

我也有兴趣看看其他人能提供的其他解决方案.

.net windows powershell cmd batch-file

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

Powershell中的"Git Log"命令 - 无法终止进程

当我输入git logPowerShell时,它会打印出看似正常响应的内容.

但是在底部它没有显示提示我输入新命令的正常工作目录,它只显示:(冒号)并且没有命令工作; 不退出,不ctrl z,不ctrl c,它只打印另一个冒号.

git terminal powershell logging command

36
推荐指数
3
解决办法
9324
查看次数

如何在PowerShell中为变量分配空值?

我想为一个被调用的变量赋一个空值$dec,但它给了我错误.这是我的代码:

import-module activedirectory
$domain = "domain.example.com"
$dec = null
Get-ADComputer -Filter {Description -eq $dec}
Run Code Online (Sandbox Code Playgroud)

powershell scripting null

36
推荐指数
3
解决办法
11万
查看次数

如果正文参数以'@'开头,则发出PowerShell POST请求

我想在PowerShell中发出POST请求.以下是邮递员的身体细节.

{
  "@type":"login",
  "username":"xxx@gmail.com",
  "password":"yyy"
}
Run Code Online (Sandbox Code Playgroud)

如何在PowerShell中传递此内容?

rest powershell powershell-5.0

36
推荐指数
3
解决办法
9万
查看次数

检查字符串是不是NULL还是EMPTY

在下面的代码中,我需要检查版本字符串是否为空,然后将其值附加到请求变量.

if ([string]::IsNullOrEmpty($version))
{
    $request += "/" + $version
}
Run Code Online (Sandbox Code Playgroud)

如果有条件,如何检查?

powershell

36
推荐指数
4
解决办法
14万
查看次数

通过Windows Powershell创建新文件

我用谷歌搜索了下面的问题,但找不到任何答案.有人可以帮我这个; 通过Windows Powershell创建新文件的命令是什么?

windows powershell createfile

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