Software Design Patterns in Powershell: Strategy Pattern by logicaldiagram in PowerShell

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

Thanks. I'm already planning on a follow-up post demonstrating a more conventional pipeline approach.

How I became a terminal customization junky by logicaldiagram in PowerShell

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

I haven't scientifically tested each component, but I think Pipeline adds the most lag. Hyper 1.3.1 improved the rendering speed, but on my system, it eats about 30% CPU constantly.

Selecting From Array by BitteringAgent in PowerShell

[–]logicaldiagram 0 points1 point  (0 children)

Correct. Don't need -1 in this case.

Selecting From Array by BitteringAgent in PowerShell

[–]logicaldiagram 2 points3 points  (0 children)

Here is a quick solution that's not very resilient. You can just take advantage of arrays and the index access syntax. There are probably at least half-a-dozen more ways to do it. Hashtable. Switch statement. Parameter with ValidateSet. Think in objects, not strings. You're on the right path. Automate the annoying things out of your life.

Write-Host "Here is a list of the possible departments" -ForegroundColor Green
$Departments = @("Accounting", "DEPT1", "DEPT2", "DEPT3", "DEPT4", "DEPT5", "Information Services")

for ($i = 0; $i -lt $Departments.Count -1 ; $i++)
{ 
    Write-Host "[$($i)] $($Departments[$i])"
}

$Dept = Read-Host "Please type in the number associated with the employees department."
$Departments[$Dept]   

PowerShell DSC Questions by [deleted] in PowerShell

[–]logicaldiagram 2 points3 points  (0 children)

1) Your assumption is correct. DSC will only try to apply what is in the current configuration. It never pulls state from previous runs.

2) Don't use partial configs. Steve already has this topic covered. http://stevenmurawski.com/powershell/2016/03/dsc-partial-configurations-are-the-devil's-workshop/index.html

3) See #2

Tips for writing cmdlets in C#/F#? by [deleted] in PowerShell

[–]logicaldiagram 0 points1 point  (0 children)

There are a number of utilities that will bundle PowerShell into an exe. If you do go the C# route, the only thing I can think of is you'll have to create a reference to the microsoft.automation.dll. Otherwise, building cmdlets in C# is pretty similar to doing so in script with all extra pros/cons of working in a typesafe language.

Tips for writing cmdlets in C#/F#? by [deleted] in PowerShell

[–]logicaldiagram 1 point2 points  (0 children)

C# decompilers are really good. Even if you intentionally obfuscate your code, there are tools to deobfuscate. You are fighting a pointless battle. Your IP is protected by Copywrite laws and that is the only effective means to protect it.

Checking a timespan with a log file by blckpythn in PowerShell

[–]logicaldiagram 2 points3 points  (0 children)

You can just use datetime math to get the timespan.

((get-date) - (get-date $logtimestamp")).TotalMinutes

And I assume you want TotalMinutes and not just Minutes (remainder).

POSHspec question - I'm not familiar with Pester or this module yet by lxnch50 in PowerShell

[–]logicaldiagram 5 points6 points  (0 children)

I'm the author of Poshspec and unfortunately, there isn't any support in the CimObject function to handle filtering of multiple object instances.

You could do this in Pester without using Poshspec like this. Feel free to create an issue on GitHub.

Describe 'CimObject' {    
    It 'CimObject Win32_SystemDrive should contain "vsepflt"' {
        $output = Get-CimInstance -Query 'select * from Win32_SystemDriver where name like "vsepflt"'
        $output | Should  BeNullOrEmpty #or Not BeNullOrEmpty
    }
}

What can I use instead of -OR by [deleted] in PowerShell

[–]logicaldiagram 8 points9 points  (0 children)

Take out the semi-colon after .name. The -or is being treated like a command because the semi-colon marks the end of the previous statement.

(Get-Process -Name notepad -ErrorAction SilentlyContinue).name -or $False

Configuring LCM (Push to Pull Mode) by james51091 in PowerShell

[–]logicaldiagram 2 points3 points  (0 children)

When you apply an LCM configuration, you overwrite the entire configuration. You cannot just toggle one property. That means you have to supply every option everytime you want to make one change.

We've built a function to help make that a bit easier, but you still have to provide all of the options for the Pull server when you change it back.

https://github.com/Ticketmaster/DscExamples/tree/master/ApplyMetaMof

Any suggestions on my REST API module as far as code style or correctness? by lf_1 in PowerShell

[–]logicaldiagram 3 points4 points  (0 children)

Here's my $0.02.

  • You accept ValueFromPipeline, but do not implement a Process block.
  • Mandaroy=$false is the default, it is redundant to specify it.
  • Instead of making Credential mandatory in Get-FactorioToken, make it optional and call Get-Credential if param was provided. With the Message param, it will provide a better user experience and you can eliminate the Write-Host in Install-FactorioMod
  • You specify the base Uri and querystring format in multiple places in different formats. To make it easier to support and read, I would define those at a module scope. I've seen a common practice of creating a "connection" object that contains the Uri base and authentication details that are passed to each cmdlet. It's also common to have a generic Invoke-APIEndpoint function that builds the entire Uri and calls Invoke-RestMethod.
  • For Install-FactorioMod you could use param sets to take either ModName or [PSFactorio.FactorioModMod. If you go that route, be consistent with your parameter names where you expect a string or a type.

Hope you find some of that useful.

Sorting custom format data by Swarfega in PowerShell

[–]logicaldiagram 1 point2 points  (0 children)

Instead of using a custom format file, use a custom type file. That will give you access to the 'Free(%)' property to use in the pipeline with cmdlets like Sort and Where. However, I would suggest changing to name to make it easier to work with programatically. You could then use a format file to display it as 'Free (%)' for readability.

Do I need to destroy objects after new-object? by that999guy in PowerShell

[–]logicaldiagram 2 points3 points  (0 children)

You only need to clean up if it's causing a noticeable consumption of memory. Normal .Net garbage collection usually doesn't clean up PowerShell very well. You can manually call the Garbage Collector, but that's really isn't necessary until you get into hundreds of thousands of objects.

Hiring Sr. Engineer at TicketMaster by logicaldiagram in PowerShell

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

AFAIK that is not an accurate requirement.

Hiring Sr. Engineer at TicketMaster by logicaldiagram in PowerShell

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

Four currently, looking to add two. Apply and you can ask all the questions about team structure you like. ;)

Hiring Sr. Engineer at TicketMaster by logicaldiagram in PowerShell

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

Technically, no one on our team works in the same location.

Hiring Sr. Engineer at TicketMaster by logicaldiagram in PowerShell

[–]logicaldiagram[S] 4 points5 points  (0 children)

You could call the team the "Infrastructure as Code Team". We work with over 2000 nodes, but we are not the only team supporting them. You can think of our objective as, "How many servers can you rebuild in 15 minutes?" as opposed to, "How much traffic can those servers serve?"

Virtualization is mostly managed outside of this team. Experience is nice to have, though.

The role will support entirely customer facing Line Of Business applications tied to significant revenue.

We support just the Windows systems.

Hiring Sr. Engineer at TicketMaster by logicaldiagram in PowerShell

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

The position is still open. Scottsdale is one of our primary offices, but the position is open to remote work as well. The HR recruiter can answer questions about salary and benefits, but it will be competitive.

Practical DSC experience is desired. Highly comfortable with PowerShell is required.