标签: powershell-core

oh-my-posh 提示中未渲染的字符

我刚刚在 Windows 上的 PowerShell Core 7.1.1 上安装了 oh-my-posh,并且在 Windows 终端中使用 PowerShell。切换到git仓库后,提示如下: 在此输入图像描述 一些字符显示为框,应该是三角形和分支字符,例如 在此输入图像描述 我目前正在使用Cascadia字体,并尝试Meslo LG M Regular过其他一些字体,但没有任何效果。

我还将编码设置为 UTF-8,并且我可以在命令行中键入 Unicode 字符,并且它们会正确显示。

如何解决缺少方框字体的问题?

git powershell powershell-core windows-terminal

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

如何在 MacOS 上安装 powershell

我已经安装了 powershell PKG 文件,我可以从应用程序启动 powershell 在此处输入图片说明

但是,我想将它集成到 Mac 上的终端中。

根据此链接,安装 pkg 文件后,我应该能够powershell在终端上运行命令并切换到 PS 模式。

macos powershell macos-high-sierra powershell-core

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

如何在 Ubuntu 18.04 上将 Powershell Core 更新到最新版本

我有一个安装了 Powershell Core 6.1.2 的 Ubuntu 18.04 VM,我想将其更新到最新的 PowerShell Core 版本。

我怎么做?

我是否按照https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-6#ubuntu-1804上的安装说明进行操作并安装最新版本版本在旧版本之上?

是否要先删除旧版本,然后再安装新版本?你是怎样做的?

Powershell Core 中是否有工具可以执行更新?

powershell ubuntu powershell-core ubuntu-18.04

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

如何传递带有空格的标签

我正在尝试使用 Azure-CLI(使用 Powershell Core)通过变量添加多个标签。

az resource tag --tags ${tagsToAdd} --id $resource.id

在哪里 $tagsToAdd="a=b c=d"

但这只给了我一个标签:

"tags": {
    "a": "b c=d"
    } 
Run Code Online (Sandbox Code Playgroud)

这有什么问题?az resource tag --tags a=b c=d --id $resource.id正确使用会产生两个标签。

azure-cli powershell-core

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

当抛出预期错误时,Pester 测试失败

我正在尝试使用 Pester for PowerShell 来测试我的一些代码,但我无法让 Pester 处理与错误相关的工作。

以这个非常基本的例子为例 -

using module AccessTokenRequestModel

InModuleScope -ModuleName AccessTokenRequestModel -ScriptBlock {

    ### Create a new instance of the 'AccessTokenRequest' object.
    $request = [AccessTokenRequest]::new()

    Describe -Name "the 'AccessTokenRequest' module -" -Tags @("AccessTokenRequest","Get","Unit") -Fixture {
        It "Given a valid organisation, the 'GetAccessToken' method should return a valid Access Token entity." {
            $accessTokenEntity = $request.GetAccessToken("ValidOrg")
            $accessTokenEntity.PartitionKey | Should be "AccessToken"
            $accessTokenEntity.RowKey | Should be "ValidOrg"
            $accessTokenEntity.AccessToken | Should be "12345"
        }

        It "Given an invalid organisation, the …
Run Code Online (Sandbox Code Playgroud)

powershell pester powershell-core

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

Powershell $PROFILE 变量指向错误的位置。它设置的 $PROFILE 变量在哪里?

对我的机器进行一些更改后,Powershell 失败,因为 $PROFILE 变量指向与以前不同的位置,即它设置为

C:\Powershell\Microsoft.PowerShell_profile.ps1
Run Code Online (Sandbox Code Playgroud)

代替

C:\Users\user\Documents\Powershell\Microsoft.PowerShell_profile.ps1
Run Code Online (Sandbox Code Playgroud)

这会导致诸如找不到已安装模块等问题。所以我的问题是Powershell如何设置$PROFILE的值?可以改变吗?

powershell powershell-core

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

PowerShell 核心。相对路径问题

电源外壳:

$file = "text.txt"
Test-Path $file            
# True
 
Get-Location
# C:\Users\Fors1k

[IO.File]::OpenRead($file) 
# FileStream
 
[IO.FileInfo]::new($file)  
# Mode                 LastWriteTime         Length Name                         
# ----                 -------------         ------ ----                         
# -a----        05.03.2021     18:12              7 text.txt  
                      
gc $file                   
# test123
Run Code Online (Sandbox Code Playgroud)

一切都好。

PowerShell 核心:

$file = "text.txt"
Test-Path $file            
# True
 
Get-Location
# C:\Users\Fors1k

[IO.File]::OpenRead($file) 
# Exception calling "OpenRead" with "1" argument(s): "Could not find file 'C:\Windows\system32\text.txt'."
 
[IO.FileInfo]::new($file)  
# Mode                 LastWriteTime         Length Name                         
# ----                 -------------         ------ ----
# larhs          01.01.1601     3:00  
                      
gc $file                   
# test123 …
Run Code Online (Sandbox Code Playgroud)

.net powershell .net-core powershell-core

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

向 Powershell Core 脚本添加默认参数

我对 Powershell 非常陌生,我正在尝试为脚本文件中的两个参数添加默认值,但在执行时仍然要求我输入缺少的参数。

参数是

param(
    [string]
    $Build = "production",

    [bool]
    $Deploy = 1
)
Run Code Online (Sandbox Code Playgroud)

所以当我这样做时,./script.ps1 -Build我收到一个错误

/Users/akshayrajgollahalli/GitHub/gollahalli.com/script.ps1 : Missing an argument for parameter 'Build'. Specify a parameter of type 'System.String' and try again.
Run Code Online (Sandbox Code Playgroud)

但根据微软博客,这就是我正在做的。我不确定这里有什么错误。

更新 1:

另一种情况是我可能想要类似的东西./script.ps1 -Build local应该覆盖该production值。

powershell powershell-core

0
推荐指数
1
解决办法
1399
查看次数