Search Results

Search found 1743 results on 70 pages for 'powershell'.

Page 15/70 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • PowerShell and interactive external programs

    - by CC
    Hi all I'm attempting to write a PowerShell script that, among other things, runs two external programs, harvesting the output of one and providing it to the other. The problem is that the second program is interactive and asks for: - a password - an option (1, 2, or 3) - an option (Y or N) - output of external program 1 Note also that this is on XP with PowerShell v1 and .net v2.0 (no I can't upgrade) Any ideas how I would do this? CC

    Read the article

  • Indirect load of type fails in PowerShell

    - by Dan
    When invoking [System.Configuration.ConfigurationManager]::GetSection("MySection") from within a PowerShell prompt, it throws an exception because the assembly containing the type represented by "MySection" in the app config is unable to be loaded. However, I have previously loaded the assembly containing that type, and I am even able to instantiate the type directly using 'new-object'. How is the ConfigurationManager resolving types such that the assemblies already loaded into the PowerShell app domain are not visible to it?

    Read the article

  • Powershell to manipulate host file

    - by Tony
    Hello, I am looking at to see if I can create powershell script to update the contents in the host file. Anybody know if there are any examples that manipulate the host file using powershell or any other scripting lanaguages? Thanks.

    Read the article

  • Should a data warehouse developer know Powershell scripting?

    - by AEngelsrud
    I am a SQL Server (2005 & 2008) data warehouse developer (SSIS, SSAS, SSRS, SQL) and I am wondering if it would be worth the effort and time to learn Powershell scripting. Are there applicable uses from a development perspective? I understand that from a DBA view there is considerable power in Powershell for administration - does any of this translate to useful commands for a developer? Thanks!

    Read the article

  • Powershell STA watin

    - by Mike Koerner
    Wow, two posts on the same day. I was working on a quick DLL project to do some web scripting using the awsome power of Watin.  In the past I use to create a vbscript as the test handler to call the DLL but lately I got a Powershell bug to call .NET DLLs. When I tried to debug the Watin call I received: The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer. I couldn't find a quick google answer to powershell apartmentstate .  Apparently you can set the powershell apartment state by the command line -STA.  http://technet.microsoft.com/en-us/library/dd315276.aspx I've found that the powershell documentation and examples is lacking compared to the Microsoft support I've come to expect.  Why is the Powershell v2.0 in C:\WINDOWS\SYSTEM32\windowspowershell\v1.0 ?

    Read the article

  • How to Run PowerShell Commands on Remote Computers

    - by Chris Hoffman
    PowerShell Remoting allows you to run individual PowerShell commands or access full PowerShell sessions on remote Windows systems. It’s similar to SSH for accessing remote terminals on other operating systems. PowerShell is locked-down by default, so you’ll have to enable PowerShell Remoting before using it. This setup process is a bit more complex if you’re using a workgroup – for example, on a home network — instead of a domain. How to Make Your Laptop Choose a Wired Connection Instead of Wireless HTG Explains: What Is Two-Factor Authentication and Should I Be Using It? HTG Explains: What Is Windows RT and What Does It Mean To Me?

    Read the article

  • Installing an exe with Powershell DSC Package resource gets return code 1619

    - by Jay Spang
    I'm trying to use Powershell DSC's Package resource to install an exe... Perforce's P4V to be specific. Here's my code: Configuration PerforceMachine { Node "SERVERNAME" { Package P4V { Ensure = "Present" Name = "Perforce Visual Components" Path = "\\nas\share\p4vinst64.exe" ProductId = '' Arguments = "/S /V/qn" # args for silent mode LogPath = "$env:ProgramData\p4v_install.log" } } } When running this, this is the error Powershell gives me: PowerShell provider MSFT_PackageResource failed to execute Set-TargetResource functionality with error message: The return code 1619 was not expected. Configuration is likely not correct + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : SERVERNAME According to documentation, return code 1619 means the MSI package couldn't be opened. However, when I manually log in to the machine and run "\\nas\share\p4vinst64.exe /S /V/qn", the install works flawlessly. Does anyone know why this is failing? Alternately, can anyone tell me how to troubleshoot this? I pasted all the error information I got from the terminal, my log file (p4v_install.log) is a 0 byte file, and there are no events in the event viewer. I don't know how to troubleshoot it any further! EDIT: I should note that I also tried using the File resource to copy the file locally, and then install it from there. Sadly, that met with the same result.

    Read the article

  • ASP.NET PowerShell Impersonation

    - by Ben
    I have developed an ASP.NET MVC Web Application to execute PowerShell scripts. I am using the VS web server and can execute scripts fine. However, a requirement is that users are able to execute scripts against AD to perform actions that their own user accounts are not allowed to do. Therefore I am using impersonation to switch the identity before creating the PowerShell runspace: Runspace runspace = RunspaceFactory.CreateRunspace(config); var currentuser = WindowsIdentity.GetCurrent().Name; if (runspace.RunspaceStateInfo.State == RunspaceState.BeforeOpen) { runspace.Open(); } I have tested using a domain admin account and I get the following exception when calling runspace.Open(): Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Requested registry access is not allowed. The web application is running in full trust and I have explicitly added the account I am using for impersonation to the local administrators group of the machine (even though the domain admins group was already there). I'm using advapi32.dll LogonUser call to perform the impersonation in a similar way to this post (http://blogs.msdn.com/webdav_101/archive/2008/09/25/howto-calling-exchange-powershell-from-an-impersonated-thead.aspx) Any help appreciated as this is a bit of a show stopper at the moment. Thanks Ben

    Read the article

  • Stdin to powershell script

    - by Stefan
    I have a service running that can invoke an external process to modify a text stream before it is returned to the service. The text stream is handed from the service to the external process on stdout and the modified result is read from the service on stdin. The external process (command) can in other words be used as a text "filter". I would like to use a powershell script to modify the text stream. I can successfully launch a script from the service on win 2008r2 using the command "powershell -executionpolicy bypass -noninteractive ./myscript.ps1". I can make the script return text to the service on stdout using the write-host cmdlet. My problem is that I can't find a way to read the text on stdin in the script. Read-host doesn't seem to work as it requires an interactive shell. I would like to avoid writing the stdout from the service to a tmp file and read that file in the script as the service is multithreaded (can launch more than one external command at a time) and tmp file management (locking, unique filenames etc) is not desired. Is this possible or should I use for example Perl for this? Powershell seems compelling as it is preinstalled on all my win 2008 machines.

    Read the article

  • Powershell / .Net: Get a reference to an object returned by a method

    - by Dan Menes
    I am teaching myself PowerShell by writing a simple parser. I use the .Net framework class Collections.Stack. I want to modify the object at the top of the stack in place. I know I can pop() the object off, modify it, and then push() it back on, but that strikes me as inelegant. First, I tried this: $stk = new-object Collections.Stack $stk.push( (,'My first value') ) ( $stk.peek() ) += ,'| My second value' Which threw an error: Assignment failed because [System.Collections.Stack] doesn't contain a settable property 'peek()'. At C:\Development\StackOverflow\PowerShell-Stacks\test.ps1:3 char:12 + ( $stk.peek <<<< () ) += ,'| My second value' + CategoryInfo : InvalidOperation: (peek:String) [], RuntimeException + FullyQualifiedErrorId : ParameterizedPropertyAssignmentFailed Next I tried this: $ary = $stk.peek() $ary += ,'| My second value' write-host "Array is: $ary" write-host "Stack top is: $($stk.peek())" Which prevented the error but still didn't do the right thing: Array is: My first value | My second value Stack top is: My first value Clearly, what is getting assigned to $ary is a copy of the object at the top of the stack, so when I the object in $ary, the object at the top of the stack remains unchanged. Finally, I read up on teh [ref] type, and tried this: $ary_ref = [ref]$stk.peek() $ary_ref.value += ,'| My second value' write-host "Referenced array is: $($ary_ref.value)" write-host "Stack top is still: $($stk.peek())" But still no dice: Referenced array is: My first value | My second value Stack top is still: My first value I assume the peek() method returns a reference to the actual object, not the clone. If so, then the reference appears to be being replaced by a clone by PowerShell's expression processing logic. Can somebody tell me if there is a way to do what I want to do? Or do I have to revert to pop() / modify / push()?

    Read the article

  • Powershell Regex help in extracting text between strings

    - by vivekeviv
    i Have an arguments like the one below which i pass to powershell script -arg1 -abc -def -arg2 -ghi -jkl -arg3 -123 -234 Now i need to extract three strings without any whitespace string 1: "-abc -def" string 2: "-ghi -jkl" string 3: "-123 -234" i figured this expression could do it. But this doesnt seem to work. $args -match '-arg1(?'arg1'.*?) -arg3(?'arg3'.*?) -arg3(?'arg3'.*)'. THis should return $matches['arg1'] etc. So whats wrong in above expression. Why do i get an error as shown below runScript.ps1 -arg1 -abc -def -arg2 -ghi -jkl -arg3 -123 -234 Unexpected token 'arg1'.?) -arg2 (?'arg2'.?) -arg3 (?'arg3'.)'' in expression or statement. At G:\powershell\tools\powershell\runTest.ps1:1 char:71 + $args -match '-arg1 (?'arg1'.?) -arg2 (?'arg2'.?) -arg3 (?'arg3'.)' <<<< + CategoryInfo : ParserError: (arg1'.?) -arg2...g3 (?'arg3'.)':String) [], ParseException + FullyQualifiedErrorId : UnexpectedToken and also the second question is how do i make arg1 or arg2 or arg3 optional? The argument to script can be -arg2 -def -ghi. I'll take some default values for arg(1|2|3) that is not mentioned. Thanks

    Read the article

  • Technique for selectively formatting data in a PowerShell pipeline and output as HTML

    - by halr9000
    Say that you want to do some fancy formatting of some tabular output from powershell, and the destination is to be html (either for a webserver, or to be sent in an email). Let's say for example that you want certain numeric values to have a different background color. Whatever. I can think of two solid programmatic ways to accomplish this: output XML and transform with XSLT, or output HTML and decorate with CSS. XSLT is probably the harder of the two (I say that because I don't know it), but from what little I recall, it has the benefit of bring able to embed the selection criteria (xpath?) for aforementioned fancy formatting. CSS on the other hand needs a helping hand. If you wanted a certain cell to be treated specially, then you would need to distinguish it from its siblings with a class, id, or something along those lines. PowerShell doesn't really have a way to do that natively, so that would mean parsing the HTML as it leaves convertto-html and adding, for example, a "emphasis" class: <td class="emphasis">32MB</td> I don't like the idea of the required text parsing, especially given that I would rather be able to somehow emphasize what needs emphasizing in Powershell before it hits HTML. Is XSLT the best way? Have suggestions for how to markup the HTML after it leaves convertto-html or ideas of a different way?

    Read the article

  • What problem did MS solve by creating PowerShell? [closed]

    - by Fred
    I'm asking because PowerShell confuses me. I've been trying to write some deployment scripts using PowerShell and I've been less than enthused by the result. I have a co-worker who loves PowerShell and defends it at every turn. Said co-worker claims PowerShell was never written to be a strong shell, but instead was written to: a) Allow you to peek and poke at .NET assemblies on the command-line (why is this a reason for PowerShell to exist?) b) To be hosted in .NET applications for automation, similar to DCOP in KDE and how Gnome is using CORBA. c) to be treated as ".NET script" rather than as an actual shell (related to b). I've always felt like Windows was missing a decent way to bang out automation scripts. cmd is too simplistic in many cases, and WSH is too obtuse (although the combination can be used successfully, I'm not a fan). When I first heard about PowerShell I felt like Windows was finally getting a decent shell that would be able to help with automation of many tasks, but recent experiences, and my co-worker, tell me otherwise. To be clear, I don't take issue with the fact that it's built on .NET, or that it passes objects around rather than text (despite my Unix background :]), and I'm not arguing that PowerShell is useless, but from what I can see, it doesn't solve the problem I was hoping it would solve very well. As soon as you step outside of the .NET/Powershell world, things quit being nice and cozy for you. So with all that out of the way, what problem did MS solve by creating PowerShell, or is it some political bastard child as I suspect? I've googled and haven't hit upon anything that sufficiently answered that for me, but the more citations the better.

    Read the article

  • Powershell variables to string

    - by Mike Koerner
    I'm new to powershell. I'm trying to write an error handler to wrap around my script.  Part of the error handler is dumping out some variable settings.  I spent a while trying to do this and couldn't google a complete solution so I thought I'd post something. I want to display the $myinvocation variable. In powershell you can do this PS C:\> $myInvocation for my purpose I want to create a stringbuilder object and append the $myinvocation info.  I tried this $sbOut = new-object System.Text.Stringbuilder $sbOut.appendLine($myinvocation) $sbOut.ToString() This produces                                    Capacity                                MaxCapacity                                     Length                                    --------                                -----------                                     ------                                          86                                 2147483647                                         45 System.Management.Automation.InvocationInfo This is not what I wanted so I tried $sbOut.appendLine(($myinvocation|format-list *)) This produced                                    Capacity                                MaxCapacity                                     Length                                    --------                                -----------                                     ------                                         606                                 2147483647                                        305 Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Micros oft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.Powe rShell.Commands.Internal.Format.FormatEndData Finally I figured out how to produce what I wanted: $sbOut = new-object System.Text.Stringbuilder [void]$sbOut.appendLine(($myinvocation|out-string)) $sbOut.ToString() MyCommand        : $sbOut = new-object System.Text.Stringbuilder                                    [void]$sbOut.appendLine(($myinvocation|out-string))                                      $sbOut.ToString()                    BoundParameters  : {} UnboundArguments : {} ScriptLineNumber : 0 OffsetInLine     : 0 HistoryId        : 13 ScriptName       : Line             : PositionMessage  : InvocationName   : PipelineLength   : 2 PipelinePosition : 1 ExpectingInput   : False CommandOrigin    : Runspace Note the [void] in front of the stringbuilder variable doesn't show the Capacity,MaxCapacity of the stringbuilder object.  The pipe to out-string makes the output a string. It's not pretty but it works.

    Read the article

  • IEnumerable<CustomType> in PowerShell

    - by svick
    I'm trying to use Enumerable.ToList() in PowerShell. Apparently, to do that, I have to explicitly convert the object to IEnumerable<CustomType>, but I am unable to do that. It seems I can't correctly write IEnumerable<CustomType> in PowerShell. Both IEnumerable<string> and CustomType itself work correctly (the custom type I'm trying to use is called WpApiLib.Page), so I don't know what can I be doing wrong. PS C:\Users\Svick> [Collections.Generic.IEnumerable``1[System.String]] IsPublic IsSerial Name BaseType -------- -------- ---- -------- True False IEnumerable`1 PS C:\Users\Svick> [WpApiLib.Page] IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Page System.Object PS C:\Users\Svick> [Collections.Generic.IEnumerable``1[WpApiLib.Page]] Unable to find type [Collections.Generic.IEnumerable`1[WpApiLib.Page]]: make su re that the assembly containing this type is loaded. At line:1 char:51 + [Collections.Generic.IEnumerable``1[WpApiLib.Page]] <<<<

    Read the article

  • Send mail via gmail with PowerShell V2's Send-MailMessage

    - by Scott Weinstein
    I'm trying to figure out how to use PowerShell V2's Send-MailMessage with gmail. Here's what I have so far. $ss = new-object Security.SecureString foreach ($ch in "password".ToCharArray()) { $ss.AppendChar($ch) } $cred = new-object Management.Automation.PSCredential "[email protected]", $ss Send-MailMessage -SmtpServer smtp.gmail.com -UseSsl -Credential $cred -Body... I get the following error Send-MailMessage : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at At foo.ps1:18 char:21 + Send-MailMessage <<<< ` + CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage Am I doing something wrong, or is Send-MailMessage not fully baked yet (I'm on CTP 3)? Edit - two additional restrictions I want this to be non-interactive, so get-credential won't work The user account isn't on the gmail domain, but an google apps registered domain

    Read the article

  • $MyInvocation.MyCommand.Path is $null in PowerGUI script editor

    - by Polymorphix
    When trying to debug my powershell script in the powerGUI script editor (2.0.0.1082) the $MyInvocation.MyCommand.Path is $null. It works when running the script via powershell. Running it in Powershell_ise.exe (on one of our servers) also works fine. Have anyone else had the same problem or know what's wrong? Here's the my powershell version: Name Value ---- ----- CLRVersion 2.0.50727.4927 BuildVersion 6.1.7600.16385 PSVersion 2.0 WSManStackVersion 2.0 PSCompatibleVersions {1.0, 2.0} SerializationVersion 1.1.0.1 PSRemotingProtocolVersion 2.1 Server version: Name Value ---- ----- CLRVersion 2.0.50727.3082 BuildVersion 6.0.6002.18111 PSVersion 2.0 WSManStackVersion 2.0 PSCompatibleVersions {1.0, 2.0} SerializationVersion 1.1.0.1 PSRemotingProtocolVersion 2.1

    Read the article

  • Powershell replace lose line breaks

    - by Fadrian Sudaman
    Hi, I am a newbie in powershell. I have a simple powershell script that just replace text but I found that the regex replace turn my multiline data source into a single line text when the output is produced. I want the line breaks to be preserved. Here is the dumb down version of the script. $source=(Get-Content textfile.txt) $process1 = [regex]::Replace($source, "line", "line2") $process1 | out-file -encoding ascii textfile2.txt You can create a test file call textfile.txt with simple lines like this to test it line line Some line More line here Have I missed something obvious? Thanks, Fadrian

    Read the article

  • PowerShell dataGridView - Copy only one Row into an other dataGridView

    - by Marcel L.
    I´ve got a very short question about the "dataGridView". I´m developing with the Microsoft PowerShell and I want to copy one Row (from $dataGridView1) to the other ($dataGridView2). With this Code I can only Copy the Value of the last focused Cell. I´ve tried to make this for a whole Row, but it´s only working with Cells. Here is my Code: **$btnListeAdd.Add_Click({ $Row = $dataGridView1.Rows[ $dataGridView1.CurrentCell.RowIndex ] $dataGridView2.Rows.Add( $dataGridView1.CurrentCell.Value ) $dataGridView1.Rows.Remove( $Row ) }) $tabListe.Controls.Add($btnListeAdd)** Only the market Cell in $dataGridView1 (similar Column 1 or 2) will be cloned in Column1 in $dataGridView2 - in a extra Row, yey. Thanks for helping me. Please show mercy. It´s my first day with the PowerShell. Kind regards, Marcel L.

    Read the article

  • Powershell script to create scheduled tasks from csv file

    - by Rihan Meij
    I would like to use Powershell to create a couple of scheduled tasks, on a server. I have created the file from existing schedule's I have loaded up the csv file, piped it to a select, and retreived all the info that I require from the csv file. However I am not sure on how to pass these results on to a external non powershell command. Import-Csv .\listoftasks.csv | Select 'Run As User','RP','Scheduled Type','TaskName','Task To Run','Repeat: Every','Repeat: Until: Duration' What I would like to do is something like: Import-Csv .\listoftasks.csv | Select 'Run As User','RP','Scheduled Type','TaskName','Task To Run','Repeat: Every','Repeat: Until: Duration' | schtasks /create /RU ....

    Read the article

  • Accessing TFS from Powershell

    - by w4ymo
    Hello I am new to PowerShell and I am trying to get branches from TFS and merge them using a PowerShell script. Unfortunately I am failing a first hurdle. I do have Visual Studio 2010 install on my local machine and can access the TFS server (also 2010) fine. I am running the script from my local machine and have the following lines: $tfs = get-tfs http://TFSServerName:8080/TFSProject $branchfolders = $tfs.VCS.GetItems('$/Dev/Branches/', $tfs.RecursionType::OneLevel) and I receive the following error on the second line 2 above Exception calling "GetItems" with "2" argument(s): "Unable to connect to the remote server" I have configured the TFS server to accept incoming connections on port 8080 which works but I am now not to sure how to resolve this error. Is further configuration required? Thanks for any help given.

    Read the article

  • Powershell: resolve path that might not exist?

    - by Eamon Nerbonne
    I'm trying to process a list of files that may or may not be up to date and may or may not yet exist. In doing so, I need to resolve the full path of an item, even though the item may be specified with relative paths. However, Resolve-Path prints and error when used with a non-existant file. For example, What's the simplest, cleanest way to resolve ".\newdir\newfile.txt" to "C:\Current\Working\Directory\newdir\newfile.txt" in Powershell? Note that System.IO.Path's static method use with the process's working directory - which isn't the powershell current location.

    Read the article

  • Trouble with Powershell and running a complex commandline

    - by Frank Rosario
    Hi, I've been trying to run the following command line from a Powershell build script we have; but keep running into issues & 'C:\Dev\Yadda\trunk\BuildScripts\U tilities\csmanage.exe' /create-deployme nt /name:yadddayaddyaddadev /label:yadddayaddyaddadev /package:https://yadddayaddyadda.blob.core.windows.net/mydeployments/20100426_202848_FamilyMoments.cspk g /config:C:\Dev\WalmartOne\trunk\yadddayaddyadda.CloudService\bin\Debug\ServiceCon figuration.cscfg /slot:Staging /hosted-service:yadddayaddyadda-dev" Note: the space in "Utilities" is intentional; trying to snif out a bug involving spaces in the executable path. I assure you, the path does exist with the space in it on my machine. What's the best way to call this command line from Powershell? I've tried Invoke-Expression, Diagnostic.Process::Start, &; each method coming up with some different type of error; usually that it could find the executable. Any constructive input is greatly appreciated. Thanks.

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >