powershell-core

Deploy Code from GitLab Repository to Azure Web App using PowerShell and Azure CLI

旧城冷巷雨未停 提交于 2019-12-24 08:58:42
问题 I would like to setup continuous deployment from a GitLab repository to an Azure App using a PowerShell script and the Azure CLI. There is already an answer for doing this using the Azure RM module and Windows PowerShell, but as these are now deprecated, I am looking specifically for a solution that uses the new Az module and PowerShelll Core. The solution should give a a PowerShell (Core) script to setup a Continuous Deployment directly from GitLab to Azure. It must make use of the Az module

PowerShell 6 - support for Windows GUI libraries

淺唱寂寞╮ 提交于 2019-12-24 06:16:07
问题 I understand that the new PowerShell 6/core lacks support for Windows GUI libraries, I have developed some important projects in PS-5.1 using the Windows.Forms .NET classes. Problem: We are planning to upgrade to PowerShell 6 this summer, which means I will lose all the GUI functionalities (developed using Windows.Forms). Question: What should we do in this situation in order to retain the GUI functionality in our PS apps. Do you envisage Microsoft will provide any alternatives for GUI

how to get the HostName from powershell?

微笑、不失礼 提交于 2019-12-24 03:00:49
问题 How do I get the hostname for dur from powershell? PS /home/thufir/powershell> PS /home/thufir/powershell> ./hostname.ps1 google.com localhost PS /home/thufir/powershell> PS /home/thufir/powershell> cat ./hostname.ps1 $hosts = ("google.com", "localhost") foreach($i in $hosts) { $fqdn = [System.Net.Dns]::GetHostEntry($i).HostName write-host $fqdn } PS /home/thufir/powershell> PS /home/thufir/powershell> hostname dur PS /home/thufir/powershell> The FQDN for the system is actually dur.bounceme

Is there a reason for the different behaviour of PowerShell aliases 'ls' and 'dir' between the windows and OS X implementations

穿精又带淫゛_ 提交于 2019-12-23 02:35:07
问题 Does anyone know the reason for the difference in output between the below 2 cases? The output from alias ls differs from the output of alias dir on OSX. In an example shown in the PowerShell help for Help Get-Content -Examples : dir ./*.txt | foreach {Get-Content $_ -Head 1; Get-Content $_ -Tail 1} works as per the example. However, if dir is replaced with ls : ls ./*.txt | foreach {Get-Content $_ -Head 1; Get-Content $_ -Tail 1} an error is returned: ls: ./*.txt: No such file or directory

How to parse html in Powershell Core

不羁的心 提交于 2019-12-22 11:16:11
问题 So, Invoke-WebRequest in Powershell Core is permanently baked with -UseBasicParsing . More details can be found here and here. Net result - no ParsedHtml property on the result object. While the rationale makes perfect sense, the question is - how to parse HTML in Powershell Core? Now, I can probably use a .NET Core library, like HtmlAgilityPack, but it seems like vast code changes would be required to migrate existing PS code to use this library. Is this our best option or are there any

Delay-bind script block does not work when function is exported from module

只愿长相守 提交于 2019-12-19 11:39:04
问题 I have following function: function PipeScript { param( [Parameter(ValueFromPipeline)] [Object] $InputObject, [Object] $ScriptBlock ) process { $value = Invoke-Command -ScriptBlock $ScriptBlock Write-Host "Script: $value" } } When I define this function directly in script and pipe input into it I get following result which is expected: @{ Name = 'Test' } | PipeScript -ScriptBlock { $_.Name } # Outputs: "Script: Test" But when I define this function inside module and export it with Export

Duplicated HelpFiles (about_) prevent Get-Help to display information. How to fix it?

痴心易碎 提交于 2019-12-19 10:14:08
问题 Problem: I have two about_psreadline help topics: about_psreadline and about_PSReadLine . Get-Help cmdlet cannot display information on any of them. Get-Help about_psreadline just displays a table with two mentioned help files. Question: How to deal with duplicated HelpFiles? Could/Should one of them be removed? Powershell version : 6.1.3; I also checked PSModulePath and the only path containing PSReadline is C:\program files\powershell\6\Modules 回答1: Whenever Get-Help shows a list of topics

Invoke-Sqlcmd cmlet missing in Powershell core sqlserver module for linux

心已入冬 提交于 2019-12-14 03:50:04
问题 I am using latest version of Powershell core on Linux Ubuntu 16.04. I am trying to query a sql server database using powershell's invoke-sqlcmd cmdlet. (Yes I have installed the sqlserver module) I get an error which says that it cannot find the cmdlet. The command is there in windows powershell when I install the sqlserver module. Screenshot of the same Does invoke-sqlcmd only work on Windows? If yes,is there another way I can achieve the same result in powershell core. 回答1: In PowerShell

PowerShell ISE: how to run new PowerShell version

那年仲夏 提交于 2019-12-10 02:35:06
问题 How can I get PowerShell ISE to work with PowerShell 6.0. Currently, it has 4.0. This server has PowerShell 4.0 installed and I installed PowerShell 6.0 with PowerShell-6.1.0-win-x64.msi from this link: https://github.com/PowerShell/PowerShell/releases The files now exist in C:\Program Files\PowerShell\6. However, ISE still shows 4.0, but I need it to run 6.0 $PSVersionTable.psversion Major Minor Build Revision 4 0 -1 -1 回答1: PowerShell has 3 executables... Windows only... PowerShell_ISE.exe

windows core run command with elevated privileges

我的梦境 提交于 2019-12-08 07:52:56
问题 There are a few options for standard user to run as Administrator (or any another user), however, even when logged as Administrator, some functions requires to run 'elevated'. On a windows gui, just right click a .exe and select run as Administrator or even elevate 'cmd' or 'powershell'. How can you get elevated privileges on Windows core? 回答1: Generally, to programmatically invoke an executable with elevation (Run as Administrator) on Windows, use the Start-Process cmdlet with -Verb RunAs .