标签: powershell-ise

如何在powershell中测量窗口高度(行数)?

我的环境中的最大行数是 47。

我可以通过编程来测量这个值吗?

powershell powershell-ise windows-console

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

Powershell 2 ISE,不停止导入模块中的断点

当我们在模块中设置断点时,我们导入调试器会忽略断点.有没有人见过这种行为?
这让我疯狂,我们广泛使用PowerShell模块.
真的很奇怪的是,如果我运行get-psbreakpoint,我可以看到断点

PS H:\Projects\Powershell> get-psbreakpoint | format-list -force


Id       : 0
Script   : H:\projects\Powershell\Shared\SFTP\SFTP.psm1
Line     : 25
Column   : 0
Enabled  : True
HitCount : 0
Action   : 

Id       : 1
Script   : H:\projects\Powershell\Trading\CPPIB\scripts\CppibBorrowReturns.ps1
Line     : 12
Column   : 0
Enabled  : True
HitCount : 1
Action   : 
Run Code Online (Sandbox Code Playgroud)

编辑:如果我删除psd1(清单文件)似乎工作

powershell module powershell-ise

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

PowerShell ISE为什么不让我在以管理员身份运行时设置断点?

由于未能使PowerGUI正常工作,我已经退回到PowerShell ISE上了.但是,如果我以管理员身份运行它,它将不允许我设置任何断点.

如果我正常启动(我的登录是管理员的成员)一切都很好,但因为我需要编写一些需要完全管理员权限的任务,这是不好的.

我已将脚本保存为正确的文件(即它不是"untitled1.ps1"),但没有快乐.

我正在运行Windows 7 x64 Ultimate.

奇怪的是,这似乎不是我的Windows 2008 R2开发盒上的问题(我以管理员的成员身份登录,然后以"管理员身份"运行PS ISE,并设置并点击断点.

任何想法为什么会这样?

powershell powershell-ise powershell-2.0

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

PowerShell脚本只导出文件名列表而没有文件扩展名,然后输出到每个目录单独的文本文件

我需要一个PowerShell脚本来导出文件名列表,只有没有文件扩展名,然后输出到每个子文件夹单独的文本文件.我需要在脚本中指定父目录,然后PowerShell需要关闭并使用文件名的子文件夹名称为每个子文件夹创建单独的文本文件(没有空格和小写).然后,在创建的每个基于子文件夹的文本文件中,都有一个文件名列表,这些文件名包含在每个子文件夹中,没有文件扩展名.

$files = Get-ChildItem -Path "M:\Music" -Recurse `
| Where-Object {`
    $_.DirectoryName -notlike "*Other\Children" -and `
    $_.DirectoryName -notlike "*Other\Numbers" -and `
    $_.Extension -eq ".mp3"}
#Now loop through all the subfolders
$folder = $files.PSisContainer
ForEach ($Folder in $files)
{
$ParentS = ($_.Fullname).split("\")
$Parent = $ParentS[@($ParentS.Length - 2)]
Select-Object BaseName > C:\Users\me\Documents\$parent.txt
}
Run Code Online (Sandbox Code Playgroud)

好的,花了一些时间在这上面,脚本在下面添加到上一次尝试.看起来我这次非常接近,但最后写入文本文件不是100%,我使用Out-File之前在每个文本文件的底部留下一个我不想要的空白行.为什么我切换到[system.io.file] :: WriteAllText和[system.io.file] :: AppendAllText,但是每个都有他们的特性不能满足我的需要.在文本文件中,我需要一列中没有空行的文件列表.

$files = Get-ChildItem -Path "M:\Music" -Recurse `
| Where-Object {`
    $_.DirectoryName -notlike "*Other\Children" -and `
    $_.DirectoryName -notlike "*Other\Numbers" -and `
    $_.Extension -eq ".mp3"}
#Now …
Run Code Online (Sandbox Code Playgroud)

powershell powershell-ise powershell-2.0 powershell-3.0

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

如何将文件复制到PowerShell中的多个文件夹

我正在运行一个脚本,其中有多个环境,可以从弹出的窗口中选择.我遇到的唯一问题是当我想要设置脚本从我创建的源函数复制并立即将它放入多个位置时.

我需要帮助的部分代码发布在下面.

$Source = Select-Boss

$destination = 'D:\parts','D:\labor','D:\time','D:\money'

"Calling Copy-Item with parameters source: '$source', destination: '$destination'."

Copy-Item -Path $source -Destination $destination
Run Code Online (Sandbox Code Playgroud)

以下部分是如何在脚本中设置其余复制功能,以便您更好地了解主要部分副本的内容.

$Source = Select-Boss

$destination = 'D:\parts'

"Calling Copy-Item with parameters source: '$source', destination: '$destination'."

Copy-Item -Path $source -Destination $destination
Run Code Online (Sandbox Code Playgroud)

但是对于一个特定的部分,我需要将它复制到多个位置.我需要这样做,因为我不必更改我登录的服务器并转到另一个服务器.这一切都在一个地方完成,我希望让事情变得更容易,而不是写一大堆小编码去复制并保存在文件夹中.

powershell powershell-ise powershell-3.0

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

Powershell ISE + Vim

是否可以通过某些类似于vim的编辑模式或插件使Powershell ISE表现得像vim?

在netbeans中,我使用的是jVi,在Visual Studio中,我使用的是VsVim,PowerShell ISE是否有类似的功能?

还是应该完全放弃Powershell ISE,而仅使用vim + powershell命令行?

vim powershell powershell-ise

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

Powershell ISE 错误地将 openssl.exe 正常输出解释为错误

我正在尝试在 PowerShell ISE 中调试脚本,但我遇到了一个问题,其中一行的正常输出被 ISE 解释为错误

我已经能够简化这个问题的重现:我在https://www.openssl.org/related/binaries.html获得了任何版本的 openssl (我用 1.0.2d x86 来自链接存储库http:/ /slproweb.com/products/Win32OpenSSL.html )

我打开 Powershell ISE,导航到 exe 所在的位置并运行以下命令:

$ErrorActionPreference = "Stop"
$env:OPENSSL_CONF = ((Resolve-Path "openssl.cfg").Path)
&openssl.exe genrsa
Run Code Online (Sandbox Code Playgroud)

输出是红色的,开始是这样的:

openssl.exe : Loading 'screen' into random state - done
At line:1 char:1
+ &C:\Trayport\OpenSsl\openssl.exe genrsa
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (Loading 'screen...om state - done:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

Generating RSA private key, 2048 bit long modulus
Run Code Online (Sandbox Code Playgroud)

如果我在正常的 PowerShell 命令窗口中运行它,输出相同但为白色,不会被视为错误

Loading 'screen' into random state …
Run Code Online (Sandbox Code Playgroud)

powershell openssl powershell-ise powershell-3.0 powershell-4.0

6
推荐指数
2
解决办法
3115
查看次数

如何在 PowerShell 中使用 Set-NetConnectionProfile 更改 NetConnectionProfile 的名称

我尝试使用如何使用 Set-NetConnectionProfile 更改 NetConnectionProfile 的名称

$Profile=Get-NetConnectionProfile -InterfaceIndex 35
$Profile.Name = "Network1"            
Run Code Online (Sandbox Code Playgroud)

错误是

"Name" is a ReadOnly property.
 At line:1 char:1
+ $Profile.Name = "Network1"
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) []
+ FullyQualifiedErrorId : ReadOnlyCIMProperty
Run Code Online (Sandbox Code Playgroud)

如何更改名称的只读属性??帮我

powershell powershell-ise powershell-2.0 powershell-3.0

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

(Powershell) 捕获“Get-WinEvent : 未找到事件” Get-WinEvent

当我运行以下命令按 ID 列出日志时,它说 Get-WinEvent : No events were found that match the specified selection criteria.

如何捕获此异常并显示一条简单的消息“未找到事件”。

我运行的命令-

Get-WinEvent -FilterHashtable @{LogName="Application";ID="191"}
Run Code Online (Sandbox Code Playgroud)

我在下面尝试过,但无法使其工作-

try { Get-WinEvent -FilterHashtable @{LogName="Application";ID="191"}
    }

catch [Exception] {
        if ($_.Exception -match "No events were found that match the specified selection criteria") {
        Write-Host "No events found";
                 }
    }
Run Code Online (Sandbox Code Playgroud)

请帮忙。谢谢

powershell powershell-ise powershell-2.0 powershell-3.0

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

在命令行中找不到但在 ISE 中可用的 Cmdlet

我正在尝试在 Windows Server 2008 R2 VM 上使用 PowerShell 创建 IIS 应用程序和应用程序池。powershell脚本如下:

Param(
    [string] $branchName,
    [string] $sourceFolder
)

if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
    [Security.Principal.WindowsBuiltInRole] "Administrator"))
{ 
    Write-Warning "You do not have Administrator rights to run this script.     `nPlease re-run this script as an Administrator."
    Exit
}

$appPool = $branchName
$site = "Default Web Site"

#Add APPPool
New-WebAppPool -Name $appPool -Force 

#Create Applications
New-WebApplication -Name $branchName -Site $site -PhysicalPath $sourceFolder -   ApplicationPool $appPool -Force    
Run Code Online (Sandbox Code Playgroud)

如果我在 PowerShell ISE 中运行脚本,它运行良好,但如果我从命令行(或使用命令行的批处理文件)运行它,我会收到错误

术语 New-WebAppPool 不被识别为 cmdlet 的名称...等。 …

iis powershell cmdlets batch-file powershell-ise

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