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

How to locate nth position of \"^\" in record, Cut 2 Cols & INS...

I have over 100 text files with about 25 fields per record, fields delimited with “^”. I need to loop through the directory for files matching *TAT*.txt (about 100+ files) For all records in each...

View Article


Image may be NSFW.
Clik here to view.

Reply To: Monitor Text File for Additional Information

Hi jacob, You could try something like this: $str = @" 2013-11-17, 17:12:01 Condition: dest_path (\\Server\Folder) does not exist or is not a directory An error log was created and stored as:...

View Article


Reply To: Passing parameter to Start-Job

Thanks, How do I create a job with a Name (like -Name parameter in Start-Job cmdlet). I’m really surprised that Start-Job does not provide a way to pass arguments to scriptblock.

View Article

Image may be NSFW.
Clik here to view.

Reply To: Passing parameter to Start-Job

Using Invoke-Command? -AsJob -JobName WHATEVER All in the help file

View Article

Reply To: How to locate nth position of \"^\" in record, Cut 2 Cols...

hi, Not quite sure what your goal is, however I would look into building a function. To list all files matching *TAT*.txt get-childitem -Filter *TAT*.txt To read the contents of a file: get-content...

View Article


Reply To: Check if text file is empty

Ah. Blank lines, whitespace lines, and $null are all different things. Try this, if you’re looking for non-whitespace: if (-not ((Get-Content c:\Scripts\CurrentPass.txt -Raw) -match '\S')) {...

View Article

Reply To: Import-Module does nothing

Or make sure you’re on the domain controller logged in as an Administrator and the PowerShell console is also elevated as Administrator.

View Article

Reply To: Check if text file is empty

Slight modification and it now works! Huzzah! if((Get-Content "c:\Scripts\CurrentPass.txt") -eq ""){ Remove-Item c:\Scripts\CurrentPass.txt Rename-Item c:\Scripts\FuturePass.txt CurrentPass.txt

View Article


Image may be NSFW.
Clik here to view.

Reply To: Check if text file is empty

@Dave Wyatt Saw your post after I fixed it. Will try what you have as well. Checking for “” may not be consistent for what I need this for so your method may work better. Thank you to all who...

View Article


Reply To: Check if text file is empty

Careful there. That code will evaulate to true if there are more than one blank line in any file, even if the file also contains non-blank lines. I made a blog post on this topic a while back:...

View Article

Reply To: Check if text file is empty

Thank you Dave. I will read your blog post. And thank you to the great Don Jones as well!

View Article

Image may be NSFW.
Clik here to view.

Reply To: Import-Module does nothing

I was in as local administrator. Unfortunately, the edition of Windows 8.1 is not Pro or Enterprise so RSAT will not work p.s. I was simply trying out the effects of get-adcomputer on my local machine...

View Article

How do I capture errors and assign to variable?

Hello, Response from Receive-Job contains some errors and I want to capture those in variable for some reason those are missing from variable but do output to screen when required. Example is below....

View Article


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

use Get-Job to get the job object, and pipe it to Get-Member. You should see properties of the job object that provide access to the various pipelines. Keep in mind that in PowerShell, error messages...

View Article

Reply To: Learning – Don Jones

Expanding on Dave’s solution above, if you wanted to reinsert the dash you could add one line: $PhoneNumbers = @( "714 555 1212" "714-555-1212" "714.555.1212" "7145551212" "(714) 555-1212"...

View Article


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

Thanks. For anybody having the same issue following will capture error stream as well ($Sender | Receive-Job 2>&1)

View Article

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

And just to clarify what that’s doing: It’s taking the error pipeline (#2) and redirecting it into the main output pipeline (#1), mingling the two.

View Article


HP warranty check full script.

I got some help previously from a few people on here and thought I would post the finished script. I apologise if this is not allowed just wanted to share it with people as I find it quite useful. The...

View Article

Reply To: HP warranty check full script.

You’re fine posting it here as an attachment, but we usually send folks to the TechNet Script Gallery as a repository.

View Article

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

ErrorVariable and ErrorAction seem to work with Receive-Job just like any other cmdlet (though this test was running a local job, not remote. I don’t have another computer up on my home network at the...

View Article
Browsing all 13067 articles
Browse latest View live