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

Reply To: PSRemoting – PSSessionConfiguration – Using PSSnapin in...

Thanks, Don. I've voted and commented.

View Article


Reply To: How to make this more useful for my situation

Hopefully I understand this correctly. Part 1: You're attempting to find all Active Directory users who have an old server name used in their HomeDirectory path or in their ProfilePath. Part 2: you...

View Article


Reply To: How to make this more useful for my situation

Thanks for the input guys. I'll research what Don was talking about as it looks like there is a very good example of it from Mike. My explanation of the second option was a little wayward. Essentially...

View Article

-or Returning a false positive ??

Hi Guys, Can someone tell me why I get $TRUE with this? $foo = @('A','B','C')   if ($foo -Contains 'X') {Write-Output $foo}     if ($foo -Contains 'X' -or 'Z') {Write-Output $foo} A B C Thanks

View Article

Reply To: -or Returning a false positive ??

if (($foo -Contains 'X') -or ($foo -Contains 'Z')) {Write-Output $foo} Should give you what you expect.

View Article


Powershell Script to Export Contacts Note

I have a script that will export outlook contacts. It seems that I am unable to export the notes field. $TempPath="$env:Userprofile\appdata\local\microsoft\outlook\" $strname=$env:username #New-Item...

View Article

Image may be NSFW.
Clik here to view.

Remove folders in a directory but keep the three latest (creation date)

Hi admins! Im very new to powershell but ive heard that this is the place to ask questions/learn powershell. I have a website where code is deployed to a directory. (d:\websites) Every time some...

View Article

Reply To: -or Returning a false positive ??

If you read about_Operators, -or is a Logical operator used to 'to connect conditional statements into a single complex conditional.' Comparison operators such as -contains, -like, -eq … are doing...

View Article


Reply To: Remove folders in a directory but keep the three latest (creation...

Two cool things Powershell does is Sort easily and also has -WhatIf for testing. If the Powershell version is v3 or higher, you can use -Directory versus the PSIsContainer logic: $files =...

View Article


Reply To: -or Returning a false positive ??

To clarify further, this expression: ($foo -Contains 'X' -or 'Z') is a compound of the following two expressions: $foo -Contains 'X' 'Z' $foo -Contains 'X' is obviously false. The expression 'Z',...

View Article

Reply To: Powershell Script to Export Contacts Note

If you did a Select *, you should see all of the attributes and figure out which one is "Notes". On my client, it appears to be 'Body'. So, add Body to your Property array

View Article

Reply To: Remove folders in a directory but keep the three latest (creation...

This is one of those problems that is quite handily solved with a single pipeline, thanks to PowerShell's handy generic -Object commands for filtering / sorting / selecting: Get-ChildItem D:\Websites...

View Article

Reply To: -or Returning a false positive ??

It's interesting that Z returns true if it's casting it as boolean. Boolean is typically translated to a 0 or 1 to indicate a false or true. A bit misleading…

View Article


Image may be NSFW.
Clik here to view.

Reply To: Remove folders in a directory but keep the three latest (creation...

Hi Rob! Seems to work the way i want it but i dont understand some of the variables (($i=0;$i -lt ($files.Count -2);$i++)) Gonna try to look it up. Many thanks

View Article

Image may be NSFW.
Clik here to view.

Reply To: Remove folders in a directory but keep the three latest (creation...

Was not aware of the -Skip parameter. Learned something new!! @Johan The for "i" is a standard in most programming\scripting logic. When using notation, i represents integer and s is string and so on....

View Article


Reply To: Remove folders in a directory but keep the three latest (creation...

Thanks Dave! Your one-liner was even better for me. ( I understand whats happens :))

View Article

Reply To: -or Returning a false positive ??

Boolean is always through of as just 0 and 1, it's more accurately Zero and Non-Zero with 0 being False, and everything else being true. Although this varies from language to language on how it gets...

View Article


Reply To: Powershell Script to Export Contacts Note

Rob, Thank you for the information. I am going to have to play with the Select * and figure out that works so I can get a better fell of things. I am going to assume this will also help with the...

View Article

Reply To: Powershell Script to Export Contacts Note

You can additionally use Get-Member to see what properties are available. However, in this case I wanted to look for my test text in the Note field, so I used Select * to return all properties and...

View Article

Reply To: How to make this more useful for my situation

Not sure who posted it, but I noticed that a copy of the code I provided was posted on PoshCode.org: http://poshcode.org/5367 I'm honestly flattered, although a link to this post would have been...

View Article
Browsing all 13067 articles
Browse latest View live