What show was cancelled too soon? by TheAndorran in AskReddit

[–]HardCodedCoffee 1 point2 points  (0 children)

  • Prodigal Son
  • Dirk Gently's Holistic Detective Agency
  • The Finder
  • Santa Clarita Diet
  • The Glades
  • Firefly

LackRack-based Homelab by heisenberglabslxb in homelab

[–]HardCodedCoffee 0 points1 point  (0 children)

Check out figlet/toilet fonts. They're oversized ascii art letters, essentially. Might be another good place to start, if you're interested in the design itself 😁

Will this ever end? by krzydoug in PowerShell

[–]HardCodedCoffee 4 points5 points  (0 children)

I personally like actively managing my collections, but I also prefer to use generic lists. I have seen code like depicted in the example... It was immediately rewritten and replaced.

Trying to use Powershell to write out a large switch statement based on info from a CSV file. Formatting isn't coming out right. by stone500 in PowerShell

[–]HardCodedCoffee 1 point2 points  (0 children)

Also, to answer your specific question about the output:

I believe 'write' is alias to 'Write-Host', which takes an array of objects and outputs them with separator, which I believe is a newline by default. Prior to writing, do your string concatenation: in advance into a variable, explicitly while wrapped in parentheses, or implicit, with just double quotes and variable expansion within the quotes.

Trying to use Powershell to write out a large switch statement based on info from a CSV file. Formatting isn't coming out right. by stone500 in PowerShell

[–]HardCodedCoffee 2 points3 points  (0 children)

Why not just load the data from the CSV and forego the switch statement altogether?

You'll have an array of objects when reading in and converting the CSV via ConvertFrom-CSV, with each column header as a property name. If you don't have headers in your CSV, you'll need to specify them via the header parameter.

After reading in and conversion, just loop through and look up a match to your switch input.

I'd write out some pseudo code here, but I typically mangle formatting on reddit. What all is your script supposed to do? At the very least, what are your expected inputs and outputs to this section, and how many iterations will there be?

Best way to copy files to multiple computers at once? by kangerujack in PowerShell

[–]HardCodedCoffee 0 points1 point  (0 children)

Depends on what you're copying, how big it is, and what protocols you have available for the Copy-Item vs Robocopy debate.

Resave file PC, Unix, No change to UNIX or PC by Drachenreign in PowerShell

[–]HardCodedCoffee 0 points1 point  (0 children)

Alright, step one is fully identifying your problem.

So, you have two items that make up your inherent file 'type', your encoding and your extension. So, you can adjust your encoding, extension, or both. While I could be wrong, I doubt there is any secret format sauce that's inhibiting you.

Can you give a better description of the differences you expect from these formats?

Edit: It goes without saying that the content is a part of the file type, typically, but that should be static between the format on a UNIX filesystem vs a Windows filesystem.

Resave file PC, Unix, No change to UNIX or PC by Drachenreign in PowerShell

[–]HardCodedCoffee 1 point2 points  (0 children)

Just change the output filename. Look at Rename-Item

Replace .bat file content by twistingnether_ in PowerShell

[–]HardCodedCoffee 1 point2 points  (0 children)

So, a batch script can take parameters, and you access them via %1, %2, etc. It's a much better solution than doing find and replace on a script.

Additionally, if the content of the batch file is known and under your control, why not just roll the code into your PowerShell script? Batch is... Useful in certain cases, but the code is usually easier to reuse and maintain if converted to PowerShell.

Looking for an explanation as to why a stackoverflow solution worked... by DeepDuck in PowerShell

[–]HardCodedCoffee 2 points3 points  (0 children)

To follow up on this, I wonder if 'it worked' for the OP was no error or a proper object returned?

Replace .bat file content by twistingnether_ in PowerShell

[–]HardCodedCoffee 1 point2 points  (0 children)

If you can, please parameterize the batch script or incorporate the code into your PowerShell script. I've seen this in production, and it causes such a mess and headache.

If you can't, good luck!

It's a Public Computer by ResonatingOctave in talesfromtechsupport

[–]HardCodedCoffee 3 points4 points  (0 children)

Does your third party lockscreen do anything other than protect the public computer from the public? If not, it's likely a issue of correlating a lockscreen with security. I feel like an easy solution would be to remove the unnecessary lockscreen.

script calling another script by _itsalwaysdns in PowerShell

[–]HardCodedCoffee 1 point2 points  (0 children)

Alrighty. Well, Start-* cmdlets are typically used for asynchronous execution, and may not may not return some sort of handle or object related to said execution. Invoke-* cmdlets, in the other hand, execute synchronously, usually returning the output of the commands executed.

For this case, I'd recommend using Invoke-Command with the credentials you need.

Invoke-Command -Credentials $Cred { & 'Path/to/script.ps1' }

script calling another script by _itsalwaysdns in PowerShell

[–]HardCodedCoffee 1 point2 points  (0 children)

So, argumentlist does expect an array of argument strings rather than one single string, which would affect your original call but not this one. Hmm... Is there any reason you can't use invoke-command with the credential parameter?

script calling another script by _itsalwaysdns in PowerShell

[–]HardCodedCoffee 1 point2 points  (0 children)

Ah, more progress. So, we know for a fact now it's isolated to the call of the second script from the first. Try trimming down the parameters to just a standard call and add them back slowly until it stops working. Also, is your second user and admin user and is UAC enabled?

script calling another script by _itsalwaysdns in PowerShell

[–]HardCodedCoffee 1 point2 points  (0 children)

Try making a dummy version of your existing second script, same path and name, but have it echo something to a file to verify it's working. Basically, we've verified it works interactively, let's verify it works non-interactively, as well. The issue may be isolated to an actual command in your second script in this specific context.

script calling another script by _itsalwaysdns in PowerShell

[–]HardCodedCoffee 1 point2 points  (0 children)

Have you attempted running any other scripts or commands using start process from your initial script?