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

Reply To: Hashtable to Custom Object

Never mind for my comment about $PSBoundParameters. The code below works, but again only one output from the command line even if I entered the command line as Get-Arguments.ps1 -username account...

View Article


Reply To: Hashtable to Custom Object

If you’re using some tool to package the script to exe, or something like that, you’ll probably have to contact the vendor for that tool. I’ve only done that once, at a customer’s request, and I...

View Article


Reply To: Strange result when piping script to Export-CSV

Thanks a million Dave! Never would’ve looked there to find the solution… Tested it out and worked like a charm. Just for other people reading it, I’ve used the Out-Null solution and it works perfectly...

View Article

Cannot use variable as a get-adcomputer filter parameter

I’ll omit the bulk of my script and just focus on this piece that is not working. Maybe there is an easier way to accomplish this. $filter = "-filter 'name -like" + "...

View Article

Reply To: Cannot use variable as a get-adcomputer filter parameter

That’s because you’re putting the “-filter” parameter name into the quotes. Doesn’t work like that. Get-ADComputer -filter $filter Would be more correct, if you took “-filter” out of $filter. As-is,...

View Article


Reply To: Cannot use variable as a get-adcomputer filter parameter

The post is a bit malformed with HTML stuff, but here’s how it should look: Get-ADComputer -Filter "Name -like '$computername'" You can sometimes get away with using curly braces and script block...

View Article

Reply To: Cannot use variable as a get-adcomputer filter parameter

Thank you so much for your help. I got the -filter variable working based on your suggestions. Now I’ve run into one more problem. At the end when I out my $obj, it outputs fine on screen but when I...

View Article

Reply To: Cannot use variable as a get-adcomputer filter parameter

You’re exporting to the CSV file inside a loop (and without the -Append parameter, which was added in PowerShell 3.0). Typically, what you’d want to do in PowerShell is have your Get-ComputerInfo...

View Article


Reply To: Cannot use variable as a get-adcomputer filter parameter

The -append did it. Thank you so much!

View Article


Reply To: Removing "test" configuration from a machine during...

My question was about “resetting” a nodes configuration, so your reply makes sense. I intend to try and use “snapshots” during development, but if that wasn’t available I was also looking for ideas on...

View Article

IP Address Math

Is there a native way in PowerShell to do IP math? Take for example I want to use the network 10.0.0.0/22 and find all pingable devices on the network. It’s a simple example but I should be able to...

View Article

Reply To: IP Address Math

As luck would have it, this was part of the practice event in the scripting games (given CIDR notation of a subnet, identify computers on the subnet, collect inventory data, etc.) Here’s how I...

View Article

Keep IF statement results

Hi there I have a script that finds out if the user is in the right addresslist in exchange based on the addresslist filter(which is based on group membership) so something like this:...

View Article


Reply To: Keep IF statement results

Try { $InDepartment = $False if ((Get-ADuser $user.alias -Properties showInAddressBook) -notmatch “department1″) { $InDepartment = $True } } Catch { # $user.alias wasn’t found } This way,...

View Article

Reply To: Removing "test" configuration from a machine during...

So… you’ve asked a few things, maybe :). You can shut the LCM off so it stops checking, yes. But you can’t “remove” a config. It isn’t like Group Policy; a config applies, and whatever it does is...

View Article


Delete old files script error, path too long.

I am getting this error running this script and wondering if there is something else that can be done with this to make it work with the long file names? I would appreciate any help! Get-ChildItem :...

View Article

Reply To: Keep IF statement results

Thanks that sounds good but since I have around 30,000 users to check in multiple groups I wanted to “collect” the users that aren’t in the list(the negatives/write-host “not in list”) so at the end...

View Article


Reply To: Delete old files script error, path too long.

Note! There might be ways to achieve this a lot easier than the one I suggest below, but this is at least one way to solve your problem. What you can do, is ‘subst’ a temporary drive folder to the...

View Article

Reply To: Keep IF statement results

So you have to think like PowerShell. Let’s say your script is named FindPeople.ps1. In it, you would use Write-Output to write out the names you want in the CSV file. Then run… .\FindPeople.ps1 |...

View Article

Reply To: Delete old files script error, path too long.

Thank you for the help and I will read the above blog posts also and will let you know what I come up with or if I figure out something that works. God bless!

View Article
Browsing all 13067 articles
Browse latest View live