powershell-3.0

Can Powershell Receive-Job return a DataSet?

試著忘記壹切 提交于 2020-01-02 05:18:11
问题 Background Info : I have an application that makes several SQL connections to multiple databases which currently takes a very very long time to execute. Powershell (.NET) will wait for each proceeding " SQL-GET " function to finish before it can fire off the next. I am under the impression I can speed this app up dramatically by firing each " SQL-GET " function in their own background job simultaneously!I will then retrieve the data from each job as they finish. Ideally as a DataSet system

Powershell click on javascript link

拈花ヽ惹草 提交于 2020-01-01 19:32:10
问题 Here is hyperlink code <a href="javascript:void(1)" onclick="server_playOn(17,2, 'est', this);"> Example </a> Here is my current powershell code. Get-Process iexplore | Foreach-Object { $_.CloseMainWindow() } $username = "user" $password = "pass" $ie = New-Object -comobject InternetExplorer.Application $ie.visible=$true $ie.FullScreen=$true $ie.navigate("http://www.example.com/en/index.shtml") while($ie.ReadyState -ne 4) {start-sleep -m 100} trap [Exception] { # This will happen if you're

How do I download a protected file using PowerShell?

拥有回忆 提交于 2020-01-01 11:42:10
问题 I am trying to download a file using PowerShell 3.0 from my TeamCity build server. I have configured TeamCity to use NTLM authentication but I cannot download the file directly and get redirected to login. I am trying to use the following PowerShell code to download the file. $artifacts = "http://teamcity/repository/download/bt1/.lastSuccessful/%7Bbuild.number%7D.zip" Invoke-WebRequest -Uri $artifacts -UseDefaultCredentials My response from the request is a redirection to the login page. 回答1:

How do I call a parameterless generic method from Powershell v3?

与世无争的帅哥 提交于 2020-01-01 02:08:01
问题 For example I have a .NET object $m with the following method overloads: PS C:\Users\Me> $m.GetBody OverloadDefinitions ------------------- T GetBody[T]() T GetBody[T](System.Runtime.Serialization.XmlObjectSerializer serializer) If I try to invoke the parameterless method I get: PS C:\Users\Me> $m.GetBody() Cannot find an overload for "GetBody" and the argument count: "0". At line:1 char:1 + $m.GetBody() + ~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodException +

How do I properly use the FolderBrowserDialog in Powershell

我的未来我决定 提交于 2019-12-30 18:25:13
问题 So I'm still fairly new to Powershell and I'm trying to write a script that allows the user to select a file or folder and then get back the security permissions for said folder/file. The problem is, I can't seem to get the file path to record as a variable to be used later. Here's what I have so far: Function Get-Folder($initialDirectory) { [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") $foldername = New-Object System.Windows.Forms.FolderBrowserDialog $foldername

Using -f operator on a string that contains curly braces

萝らか妹 提交于 2019-12-30 05:56:35
问题 Consider the following here-string that I am trying to use a template for my Nagios definitions. $blankDefinition = @" define host{ use windows-server ; Inherit default values from a template host_name {0} ; The name we're giving to this host alias {0} ; A longer name associated with the host address {1} ; IP address of the host } "@ I have a script that determines which of my servers are not in nagois that should be. As it loops I'm trying to have it spit out a definion for me so that I can

Create powershell parameter default value is current directory

淺唱寂寞╮ 提交于 2019-12-30 05:20:07
问题 I'm hoping to create a parameter who's default value is the 'current directory' ( . ). For example, the Path parameter of Get-ChildItem : PS> Get-Help Get-ChildItem -Full -Path Specifies a path to one or more locations. Wildcards are permitted. The default location is the current directory (.). Required? false Position? 1 Default value Current directory Accept pipeline input? true (ByValue, ByPropertyName) Accept wildcard characters? true I created a function with a Path parameter that

PowerShell cmdlet parameter value tab completion

本秂侑毒 提交于 2019-12-30 02:00:06
问题 How do you implement the parameter tab completion for PowerShell functions or cmdlets like Get-Service and Get-Process in PowerShell 3.0? I realise ValidateSet works for a known list, but I want to generate the list on demand. Adam Driscoll hints that it is possible for cmdlets but unfortunately hasn't elaborated. Trevor Sullivan shows a technique for functions, but as I understand it, his code only generates the list at the time the function is defined. 回答1: Check the TabExpansionPlusPlus

Using PowerShell 2 as the default version on Windows 8

本秂侑毒 提交于 2019-12-29 08:39:08
问题 I would like to use PowerShell 2 as the default PowerShell version on Windows 8 without specifying the -Version switch. I started using Windows 8 RTM which comes with PowerShell 3, and I have scripts that are not compatible with PowerShell 3. 回答1: Powershell uses a publisher policy (see here also) to automatically redirect hosts built against Powershell 2 onto the Powershell 3 runtime if it's available. Most of the time this is exactly what you want, however you can explicitly disable the

Does powershell remoting support version of the powershell to be used on remote target?

徘徊边缘 提交于 2019-12-29 08:25:09
问题 Can I supply a version of powershell to be used on the target machine while ps remoting. May be my question is not proper or not possible to answer but if any body having idea please help me. I am trying to do a remoting using powershell on a machine where powershell 2.0 3.0 and 4.0 versions are available , but I want to use the version 4.0 only (on target machine) is it possible? Thanks Gyan 回答1: Yes, there is a way to connect to a specific version of Powershell on a remote machine. It does