powershell

Change DataSource of SSRS Report with Powershell

你。 提交于 2020-12-01 09:52:39
问题 I'm trying to ahange data sources of multiple SSRS Report with Powershell to one shared data source on my reporting server. Here my code: cls; $reportserver = "myServer";<br/> $url = "http://$($reportserver)/reportserver/reportservice2005.asmx?WSDL";";<br/> $ssrs = New-WebServiceProxy -uri $url -UseDefaultCredential -Namespace "ReportingWebService"; [ReportingWebService.DataSource[]] $myDataSource = new-object ReportingWebService.DataSource $myDataSource[0].Name = "myDS"";<br/> $myDataSource

How to declare an array of strings (on multiple lines)

隐身守侯 提交于 2020-12-01 09:20:43
问题 Why does $dlls.Count return a single element? I try to declare my array of strings as such: $basePath = Split-Path $MyInvocation.MyCommand.Path $dlls = @( $basePath + "\bin\debug\dll1.dll", $basePath + "\bin\debug\dll2.dll", $basePath + "\bin\debug\dll3.dll" ) 回答1: You should use something like: $dlls = @( ($basePath + "\bin\debug\dll1.dll"), ($basePath + "\bin\debug\dll2.dll"), ($basePath + "\bin\debug\dll3.dll") ) or $dlls = @( $($basePath + "\bin\debug\dll1.dll"), $($basePath + "\bin\debug

How to declare an array of strings (on multiple lines)

半腔热情 提交于 2020-12-01 09:18:35
问题 Why does $dlls.Count return a single element? I try to declare my array of strings as such: $basePath = Split-Path $MyInvocation.MyCommand.Path $dlls = @( $basePath + "\bin\debug\dll1.dll", $basePath + "\bin\debug\dll2.dll", $basePath + "\bin\debug\dll3.dll" ) 回答1: You should use something like: $dlls = @( ($basePath + "\bin\debug\dll1.dll"), ($basePath + "\bin\debug\dll2.dll"), ($basePath + "\bin\debug\dll3.dll") ) or $dlls = @( $($basePath + "\bin\debug\dll1.dll"), $($basePath + "\bin\debug

Determine the OS version, Linux and Windows from Powershell

半世苍凉 提交于 2020-12-01 01:31:29
问题 How can I determine the OS type, (Linux, Windows) using Powershell from within a script? The ResponseUri isn't recognised when this part of my script is ran on a Linux host. $UrlAuthority = $Request.BaseResponse | Select-Object -ExpandProperty ResponseUri | Select-Object -ExpandProperty Authority So I want an If statement to determine the OS type that would look similar to this: If ($OsType -eq "Linux") { $UrlAuthority = ($Request.BaseResponse).RequestMessage | Select-Object -ExpandProperty

How to make powershell tell me about missing DLLs?

我的梦境 提交于 2020-11-30 12:41:48
问题 I use powershell as shell in Windows. When I'm trying to launch some application who's dll dependencies are missing in PATH environment variable, then nothing happens, powershell just silently returns with new command prompt. Is there a way to make powershell fail louder, telling me what exactly is missing, like default cmd shell does? 回答1: I was having this same problem. PowerShell was setting $LASTEXITCODE code to -1073741515 ( 0xC0000142 , 3221225794 ) but no output explaining what was

How to make powershell tell me about missing DLLs?

被刻印的时光 ゝ 提交于 2020-11-30 12:38:31
问题 I use powershell as shell in Windows. When I'm trying to launch some application who's dll dependencies are missing in PATH environment variable, then nothing happens, powershell just silently returns with new command prompt. Is there a way to make powershell fail louder, telling me what exactly is missing, like default cmd shell does? 回答1: I was having this same problem. PowerShell was setting $LASTEXITCODE code to -1073741515 ( 0xC0000142 , 3221225794 ) but no output explaining what was

How can I “zip” two arrays in PowerShell?

你离开我真会死。 提交于 2020-11-30 11:59:38
问题 I want to zip two arrays, like how Ruby does it, but in PowerShell. Here's a hypothetical operator (I know we're probably talking about some kind of goofy pipeline, but I just wanted to show an example output). PS> @(1, 2, 3) -zip @('A', 'B', 'C') @(@(1, 'A'), @(2, 'B'), @(3, 'C')) 回答1: There's nothing built-in and it's probably not recommended to "roll your own" function. So, we'll take the LINQ Zip method and wrap it up. [System.Linq.Enumerable]::Zip((1, 2, 3), ('A', 'B', 'C'), [Func[Object

How can I “zip” two arrays in PowerShell?

▼魔方 西西 提交于 2020-11-30 11:58:04
问题 I want to zip two arrays, like how Ruby does it, but in PowerShell. Here's a hypothetical operator (I know we're probably talking about some kind of goofy pipeline, but I just wanted to show an example output). PS> @(1, 2, 3) -zip @('A', 'B', 'C') @(@(1, 'A'), @(2, 'B'), @(3, 'C')) 回答1: There's nothing built-in and it's probably not recommended to "roll your own" function. So, we'll take the LINQ Zip method and wrap it up. [System.Linq.Enumerable]::Zip((1, 2, 3), ('A', 'B', 'C'), [Func[Object

How to get Database Name from Connectionstring in PowerShell

半城伤御伤魂 提交于 2020-11-29 07:58:12
问题 I'm trying to get the Database name from a connection string in PowerShell. "Server=server\instance;uid=User;pwd=Hello;Database=SomeName;" I can think of two ways to do that, either to search for the string Database , up until the first ; after that split the string on = and select the Databasename - but I don't really know how to do that. The second way could be with the DBConnectionStringBuilder like this: $sb = New-Object System.Data.Common.DbConnectionStringBuilder $sb.set

Get-Help for .trim / -trim, .replace / -replace, .split / -split and other string operators

这一生的挚爱 提交于 2020-11-28 18:14:41
问题 PowerShell has a pretty good built-in help system that I use a lot and I'm able to see all help options with Get-Help * and query Cmdlets or can look up Topics with Get-Help about_* and then say Get-Help about_compar* to open the Comparison Operators topic which is all very good. However, I was trying to find how to get help on the various string operators, like .replace, .compare, .split, .substring. Does anyone know how to pull these topics up on the PowerShell console (possibly, they might