Alan McLaughlin Jr.

My feedback

  1. 1 vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    2 comments  ·  PowerShell » Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
    Alan McLaughlin Jr. commented  · 

    I've worked around this by setting the gridview's -outputmode to "single" and writing a function that when data is selected and OK is pressed then invoke [Windows.Forms.Clipboard]::SetText($Selection) sending the text exactly as it appears in the gridview to the clipboard. But just using a ctrl+c would be preferred.

    Alan McLaughlin Jr. commented  · 

    Including script for reference in case anyone wants to reproduce the issue:

    #MAC Formater - takes a MAC in any various standard formats and outputs it back to gridview in all standard formats. (2/16/2017) -AJM
    #Last Edit: 7-25-2017

    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
    [Collections.Arraylist]$Collection = @()
    $hyphen = ""; $colon = ""; $nodlim = ""; $dotdelim = ""

    if($Args.Count -gt 0) {$MACAddress = $Args[0]}
    else {cls;$MACAddress = [Microsoft.VisualBasic.Interaction]::InputBox("Input MAC Address`n`nField pre-loads from clipboard", "MAC Formatter", (Get-Clipboard -Format Text))}
    if($MACAddress.Length -eq 0){Return}

    $MACAddress = $MACAddress.Replace("-","").Replace(".","").Replace(":","").Replace(" ","").Replace(" ","").ToLower()

    $nodelim = $MACAddress

    if($MACAddress.Length -gt 12) {cls; "Input too long."; return}
    if($MACAddress.Length -lt 12) {cls; "Input too short."; return}

    $dotdelim = "$($nodelim.Substring(0,4)).$($nodelim.Substring(4,4)).$($nodelim.Substring(8,4))"

    $MACAddress = $MACAddress.ToCharArray()

    $i = 0
    Do{
    $colon = $colon + ":" + ($MACAddress[$i] + $MACAddress[$i + 1])
    $hyphen = $hyphen + "-" + ($MACAddress[$i] + $MACAddress[$i + 1])
    $i += 2
    }While($i -lt $MACAddress.Count)

    $colon = $colon.Substring(1,17)
    $hyphen = $hyphen.Substring(1,17)

    $Collection.Add($nodelim) | Out-Null
    $Collection.Add($nodelim.ToUpper()) | Out-Null
    $Collection.Add("") | Out-Null
    $Collection.Add($dotdelim) | Out-Null
    $Collection.Add($dotdelim.ToUpper()) | Out-Null
    $Collection.Add("") | Out-Null
    $Collection.Add($hyphen) | Out-Null
    $Collection.Add($hyphen.ToUpper()) | Out-Null
    $Collection.Add("") | Out-Null
    $Collection.Add($colon) | Out-Null
    $Collection.Add($colon.ToUpper()) | Out-Null

    Do{
    $Selection = $Collection | Out-GridView -OutputMode Single -Title "Select a MAC to copy it to Clipboard"
    If($Selection.Length -gt 0) {[Windows.Forms.Clipboard]::SetText($Selection)}
    }Until($Selection.Length -eq 0)

    Alan McLaughlin Jr. shared this idea  · 
  2. 9 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  PowerShell » Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
    Alan McLaughlin Jr. supported this idea  · 
  3. 15 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    4 comments  ·  PowerShell » Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →

    It would certainly be cool, but we’re not really investing in Out-GridView at this point in time. I’ll leave this open as a Survey to see if the demand surpasses our bar (though I’d caveat that demand would have to be fairly high).

    Thanks,
    Joey

    Alan McLaughlin Jr. commented  · 

    I've been re-writing all of my scripts to Gridviews recently. This is the best thing to happen to scripting since Powershell itself. Check out this one I wrote in January that used to output to an Excel Spreadsheet. 100x better with gridview! Would like more button options if possible. For this script Refresh/Ping/Close would be ideal.

    #Exports all DHCP entries in all scopes from targeted DHCP server to gridview for easy searching. (1/31/2017) -AJM
    #Last Edit: 7/14/2017

    If($Args.Count -gt 0){$DHCPServers = $Args[0]} #Can accept argument instead of gridview but only accepts a single server
    Else{$DHCPServers = (Get-DhcpServerInDC | Out-GridView -OutputMode Multiple -Title "Select DHCP Server(s)").DnsName} #discover dhcp servers and prompt in gridview if no argument is provided at run

    If($DHCPServers.Length -lt 1){Return} #abort if no server selected

    #output status to console
    cls;"Querying the following DHCP Servers:"
    "";$DHCPServers;"";""

    #Loop to allow refresh of query when selecting OK in gridview
    Do{
    $DHCP = @() #clear array each loop to dispose of old data during refresh

    #Loop through each DHCP server selected
    ForEach($DHCPServer in $DHCPServers){
    #Grabs all scopes from current DHCP server
    $Scopes = Get-DhcpServerv4Scope -ComputerName $DHCPServer

    #Loops through all scopes to scrub all entries into a flat table and collects them into an array, includes leases and reservations
    Foreach ($IndividualScope in $Scopes){
    $DHCP += Get-DhcpServerv4Lease -ComputerName $DHCPServer -ScopeId $IndividualScope.ScopeId.IPAddressToString | Select IPAddress,ScopeId,AddressState,ClientId,Description,Name,HostName,Type
    $DHCP += Get-DhcpServerv4Reservation -ComputerName $DHCPServer -ScopeId $IndividualScope.ScopeId.IPAddressToString | Select IPAddress,ScopeId,AddressState,ClientId,Description,Name,HostName,Type
    }
    }
    #Output list of DHCP entries to Gridview
    cls;$Selection = $DHCP | Out-GridView -OutputMode Multiple -Title "DHCP Export - Select [OK] to Refresh or [Cancel] to Exit"
    }Until($Selection -eq $null) #break loop if cancel is selected

    Alan McLaughlin Jr. supported this idea  · 
  4. 6 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    3 comments  ·  PowerShell » Microsoft.PowerShell.* Modules  ·  Flag idea as inappropriate…  ·  Admin →
    Alan McLaughlin Jr. commented  · 

    The gridview is amazing. I love it. A few simple additions like the one suggested here could send it even farther into the WOW factor. As it stands I loop the original input back into another gridview whenever a user makes a selection but I don't want gridview to close out yet. Unfortunately this removes the current Filter data. I've adjusted my script to remove the entry they selected last and add it back to the top of the menu but it would be extremely convenient if I could just pass a pre-loaded filter into the gridview as an argument. A non-closing Gridview when OK is selected would be as well.

    Out-GridView -Filter $SomeVariable -passthrough

    Out-GridView -ButtonEvent NoClose -passthrough

    Alan McLaughlin Jr. supported this idea  · 
  5. 5 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  PowerShell » Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
    Alan McLaughlin Jr. supported this idea  · 
  6. 10 votes
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)

    We’ll send you updates on this idea

    survey  ·  2 comments  ·  PowerShell » Other PowerShell  ·  Flag idea as inappropriate…  ·  Admin →
    Alan McLaughlin Jr. commented  · 

    This would be nice as an option. I don't always want it to do this but I do want it to often.

    Alan McLaughlin Jr. supported this idea  · 

Feedback and Knowledge Base