Quantcast
Channel: PowerShell.org » All Posts
Browsing all 13067 articles
Browse latest View live

Foreach loop

Coming from a Python background, how does one accomplish something along the lines of looping through each object returned from a Get-MailBox and Get-MailUser? foreach ($user in (Get-MailUser...

View Article


Reply To: How do I capture errors and assign to variable?

For some reason does not work for me PS C:\Users\admin>> Receive-Job 661 -Keep -ErrorVariable $RemoteErr The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) + CategoryInfo :...

View Article


Reply To: Foreach loop

I’m not sure I understand the question. Are you trying to combine the results of two commands into a single collection?

View Article

Reply To: Delete Line form text file

Here’s another variation … #1..100 | foreach { "pass$psItem" } >> source.txt $pass = Get-Content .\source.txt -TotalCount 1 $newList = Get-Content .\source.txt | select -Skip 1 $newList |...

View Article

Reply To: Foreach loop

Hi Dave, That is exactly right. Does powershell support such syntax or must it be nested? If so, without pipes how can you process each object returned without consuming the entire result set before...

View Article


Reply To: Foreach loop

The pipeline is PowerShell’s primary means of streaming objects instead of holding an entire result set in memory. If that’s your goal, you’ll need to stop avoiding the pipeline completely. That said,...

View Article

Reply To: Foreach loop

That’s in a nut shell how I got them in one one foreach loop. So, is it not common belief that a pipe should be avoided in a script? I am of the thought that they are not typically programmatic...

View Article

Reply To: Foreach loop

I’m not sure where that “avoid the pipeline” sound byte came from originally, but it’s been taken way out of context. It’s important to know when to use the pipeline (essentially, anytime streaming of...

View Article


Using Server 2008 R2

I could be misinterpreting this but “Learn windows PowerShell in a month of lunches – version 3″ states to get the complete functionality of PS version 3 I should install .net 3 and .net 4. 2012...

View Article


Reply To: Using Server 2008 R2

You need .NET 4.0 to install Powershell 3.0, or.NET 4.5 to install Powershell 4.0. You don’t need to worry about earlier versions of.NET unless you need to run Powershell 2.0.

View Article

Reply To: Getting error in establishing remoting

How then “NoLanguage” is supposed to work in a first place?

View Article

Reply To: Getting error in establishing remoting

Found an answer on forum post. You have to enable following to allow remoting with “NoLanguage” setting and restricted commands. “Enter-PSSession requires the Get-Command, Out-Default and...

View Article

Image may be NSFW.
Clik here to view.

Reply To: Please help with string matching

Hi Dave, I dont think i understand how to use table arrays yet, i have brought a book and its on its way In the mean time if you could point me in the right direction i would be greatfull (again) This...

View Article


Removing "test" configuration from a machine during development

During development of a new machine configuration, I’d like to be able to completely remove the currently “Pushed” configuration from the test machine. It’s not a VM, so I can’t just turn it off and...

View Article

Reply To: Two variables into on Variable

I would be interested in seeing an example of this. i am trying to find a way to call those dynamically created variables again so i can set additional attributes. Basically it is a number of servers...

View Article


Reply To: Two variables into on Variable

Once you create a variable like that, you can get it using Get-Variable. Or better, when you call New-Variable, use -PassThru to return the variable so that you catch it. That is to say, do this:...

View Article

Workflow with pipeline

I have following powershell script: function Testing { [CmdLetBinding()] Param ( [int]$MaxRetrycount = 3, [Parameter(ValueFromPipeline=$True)] [String]$Definition ) return $MaxRetrycount } workflow...

View Article


Reply To: PowerShell version 4 on Windows Server 2008 R2 domain controller

Wow, Don Jones, I am honoured to have an opportunity to talk to you. Your Windows PowerShell Ultimate Training is absolutely awesome. I was not a big fan of PS but when I had to disable 100 users I...

View Article

Reply To: PowerShell version 4 on Windows Server 2008 R2 domain controller

They are at the PowerShell Summit right now so he may not respond very quickly this week. However you’re already in the right place Don runs this site and frequents these boards so this is the best...

View Article

How to allow applications in a PowerShell 3.0 New-PSSessionConfigurationFile?

Hi! I like to allow DOS commands (applications) like Ping.exe or WhoamI.exe inside a Constrained Session. Does anybody know how to archive that with PowerShell 3.0 and an .pssc session configuration...

View Article
Browsing all 13067 articles
Browse latest View live