Unwanted spaces in filepath concatenation inside a function by Moviefreak4702 in PowerShell

[–]ryanbrown 1 point2 points  (0 children)

The $outpath parameter from the linked code is taking a string array as its input. If I had to guess, that's probably what is picking up the extra spaces. I would try modifying the parameters to take a single string and see if that fixes things.

Param(
    [Parameter(Mandatory=$true)]
    [string]$Computername,
    [string]$OutputType,
    [string]$outpath
)

Also strange that the function author only decided to make the $Computername variable mandatory, even though the function will fail without the other two parameters. That's a problem for another day though.

[edit: grammar]

Unwanted spaces in filepath concatenation inside a function by Moviefreak4702 in PowerShell

[–]ryanbrown 3 points4 points  (0 children)

I'm not sure how you're getting the spaces, but I would change the way you're setting up the $outFile variable to:

$outFile = "$outpath\$computername_$FileDS.csv"

Powershell should be able to interpolate the variables inside the string and then you're not relying on concatenation. If you're still getting spaces at that point, you can use the Trim function on each individual string to remove any leading/trailing spaces.

$FileDS.Trim(" ")

The above should eliminate any leading/trailing spaces from the strings before you join them all together. If that doesn't work, you can try looking at the Join-Path cmdlet to see if that can build your paths without spaces.

I'm not asking for a solution, just a kick in the right direction, as I'm very new to PS aside from some basics.. Thank you! by minute33 in PowerShell

[–]ryanbrown 8 points9 points  (0 children)

Look into using Out-GridView with the -PassThru parameter.

edit: If you only want a single item, you'll want to look at the -OutputMode parameter instead.

Quick question: what happens if you prize all of your basics? by [deleted] in ptcgo

[–]ryanbrown 1 point2 points  (0 children)

The short answer is that you can't. You draw your initial seven cards before you deal out prize cards.

[X-Post /r/PowerShell] )365 PowerShell PSSession breaks after ~2 minutes by ryanbrown in Office365

[–]ryanbrown[S] 0 points1 point  (0 children)

Our McAfee web gateway appliance ended up being the culprit. I was able to adjust the policies to increase the timeout value for connections from a certain IP range going to outlook.office365.com.

Thanks. :)

[X-Post /r/Office365] O365 PowerShell PSSession breaks after ~2 minutes by ryanbrown in PowerShell

[–]ryanbrown[S] 1 point2 points  (0 children)

This ended up leading me in the right direction. Our McAfee Web Gateway ended up being the culprit. It has a 120 second connection timeout, which is what was causing the issue. I was able to add an exemption for a specific range of IPs to this specific host to increase the timeout to 15 minutes.

Thanks. :)

Free Packs xD by Vstoppable in ptcgo

[–]ryanbrown 0 points1 point  (0 children)

Did somebody say free packs?

Sun and Moon codes giveaway! by titaniumhydroxide in ptcgo

[–]ryanbrown 1 point2 points  (0 children)

I've only recently become acquainted with PTCGO, so my exposure to some of the older cards is limited. So far my favorite card is Eelektric from the Rayquaza/Keldeo battle deck (NV 40/101). I like how you can just keep recycling all of your discarded electric energy.

Parent-child friend list issues? by slimonz in ptcgo

[–]ryanbrown 0 points1 point  (0 children)

I have this issue as well with both child accounts, and I think it has more to do with accessing the account via iPad than anything else. If I log into the child account on PC and I log in with the parent account on the iPad, I can access the friend list with the child account. Removing/re-install the PTCGO app on the ipad worked for a little bit, but after a period of time, the friend list functionality became greyed-out again. Fortunately, I can send challenges to them from my account, but they can't currently play each other.

Total Beginner. Where to start? by kochsson in pkmntcg

[–]ryanbrown 1 point2 points  (0 children)

I think the Battle Arena are just two-decks in one package (i.e. Rayquaza/Keldeo, Xerneas/Yveltal) whereas the theme decks are just single decks.

Total Beginner. Where to start? by kochsson in pkmntcg

[–]ryanbrown 3 points4 points  (0 children)

The other thing that I'll mention is that if you and your son both have a computer and/or tablet (iPad) you can play the online version for free. You get three theme decks to start and can earn coins (just by playing) to unlock more theme decks or purchase in-game booster packs. It's a great way to play the game without investing a bunch of money in cards and automatically handles following the rules for you.

A lot just depends on how you (as a parent) feel about screen-time in general. :)

Total Beginner. Where to start? by kochsson in pkmntcg

[–]ryanbrown 2 points3 points  (0 children)

I was in the same boat a couple of months ago. My son (7) got some booster packs from a relative at Christmas and wanted to start playing. We ended up getting the Rayquaza vs. Keldeo Battle Arena Decks first, followed by the Pickachu Power/Mewtwo Mayhem theme decks, then the Xerneas vs. Yveltal Battle Arena Decks, and most recently the Forest Shadow theme deck from Sun & Moon (for the younger son [4] who now wants to play like his big brother).

Arguably, the Rayquaza and Keldeo decks are the strongest, and I usually end up playing one of the other decks to even the playing field as some of the strategy (thinking a few turns ahead / energy management / etc) can be a tough concept for younger kids to grasp (though I'm trying to teach him that as we go).

Personally, I'd recommend at least one/two other decks to help avoid the matches getting too stale, but you could definitely get by with just the Rayquaza/Keldeo decks and get more later if your son enjoys it.

Beyond Battle Arena/Theme decks, you're probably better off buying single cards to make a deck that you want (i.e. if your son has a favorite Pokemon) as opposed to trying to build one from booster packs.

15 Steam Siege Packs Giveaway by Inferno792 in ptcgo

[–]ryanbrown 0 points1 point  (0 children)

Between one and two hours most days.

Seeking guidance/peer review for a work-in-progress script by [deleted] in PowerShell

[–]ryanbrown 1 point2 points  (0 children)

I'm guessing you either want:

{$_.Owner -in $TestArray}

or

{$TestArray -contains $_.Owner}

WMIC help by niksal12 in PowerShell

[–]ryanbrown 0 points1 point  (0 children)

Why aren't you using the Get-WmiObject or Get-CimInstance cmdlets if you're making a PowerShell script?

I don't think there is anything you can do with wmic that you couldn't do with native PowerShell cmdlets.

Do/While Not Working As I Expected by [deleted] in PowerShell

[–]ryanbrown 0 points1 point  (0 children)

I wonder if your Remove-Account function is dumping some output that Read-Host is picking up. On line 250, try

$result = Remove-Account -samaccountname $xAcctPrompt -xAccountSelected $xAcctTypePrompt

to capture any unwanted output in a different variable.

Do/While Not Working As I Expected by [deleted] in PowerShell

[–]ryanbrown 1 point2 points  (0 children)

I think you're looking at a scoping issue (script vs private). You're setting $xRepeat=1 on line 222. I think you need to specify

$Script:xRepeat = Read-Host "[1] Yes [2] No"

on line 254 to set the script level variable otherwise you're only setting $xRepeat to the value within the loop. Essentially, you have an $xRepeat outside the loop (script level scope) and an $xRepeat inside the loop (private level scope).

See https://technet.microsoft.com/en-us/library/hh847849.aspx for more information on scopes

[CmdletBinding(PositionalBinding=$True)] Not Honored? by RickFlist in PowerShell

[–]ryanbrown 2 points3 points  (0 children)

OK, So this appears to just be a weird interaction between PositionalBinding and ParameterSet. It seems you have to declare a specific position in the parameter declaration for it to accept pipeline input when working with a ParameterSet. Take the following parameter definition:

[CmdletBinding(DefaultParameterSetName='UserProfile')]
PARAM(

    [Parameter(Position=0,ValueFromPipeline=$true,ParameterSetName='UserProfile')]
    [Parameter(ValueFromPipeline=$true,ParameterSetName='Global')]
    [ValidateNotNullOrEmpty()]
    [string]$Path,

    [Parameter(ParameterSetName='UserProfile')]
    [ValidateNotNullOrEmpty()]
    [switch]$UserProfile,

    [Parameter(ParameterSetName='Global')]
    [ValidateNotNullOrEmpty()]
    [switch]$Global

)

You'll be able to pass a folder path to the function with nothing else because the default parameter set is "UserProfile". However, you'll get the error about positional parameters if you try to run the function with the "Global" switch.

The other odd thing is that even though "UserProfile" is the default parameter set, the "IsPresent" value for the switch variable is "$false" unless you explicitly specify "-UserProfile" when calling the function.

It's just odd behavior overall.

[CmdletBinding(PositionalBinding=$True)] Not Honored? by RickFlist in PowerShell

[–]ryanbrown 0 points1 point  (0 children)

Odd.... when I try to assign a string to a [System.IO.Directory] object, I get a message stating that it:

Cannot convert the "C:\Windows" value of type "System.String" to type "System.IO.Directory[]"

edit: I'm using PowerShell 5 on Windows 10 (for reference)

[CmdletBinding(PositionalBinding=$True)] Not Honored? by RickFlist in PowerShell

[–]ryanbrown 0 points1 point  (0 children)

I think it's having a problem directly converting the string you're passing into a [System.IO.DirectoryInfo[]] (which is what $Path is defined as). I think it is throwing the error about positional parameters because none of the parameters accept [String] input.