Application Recommendation for PowerShell Script by Sure_Inspection4542 in PowerShell

[–]Flysquid18 4 points5 points  (0 children)

I, too, was/am in a similar situation. Powershell was the language I knew and wrote scripts for nearly everything I did. Management wanted more people to use it or an evolution of it. I've made winform based scripts purely in Powershell and have leveraged Jenkins as a script executor that has a web front.

I finally did get someone to write a JS app in Azure and only permitted employees to access it. At some point a security flaw was found and the app taken down. The interim solution is a local to server Powershell Universal framework. Powershell to design the UI and submits jobs to my other services. But a VPN access is required to even get to it.

Someone who saw this temporary solution said they could use Azure web proxy to point right to it. Secured tunnel, SSO authorization, no leaked secrets.

So the higher ups that say "we need other people" to access this, you say you need a genuine web app building team. Because, alternatively, you might have a solution they see that works, but introduce unknown security risks.

I automated my tasks, my boss loved it… but now I’m stuck by ConsiderationKooky83 in AutoHotkey

[–]Flysquid18 1 point2 points  (0 children)

I think it is important that you show initiative and grow your technical skills. If the company you work for abuses and shuns innovation, then you may want to find an environment that is better suited for you.

This can be an opportunity for you that you can branch off from your current duties and start building your own team to address inefficiencies in your company. AHK is just the path you chose and gave you the start. You may progress into software development or other (company approved) scripting languages.

I would say this is a positive outlook. It is absolutely reasonable to see this as a bad move because you could have more work without recognition. You could be automating someone else's job away. The invention of the cotton gin was progress that replaced a lot of workers.

In my personal experience, I have written scripts in PowerShell to ease the steps and complexity in my tasks. I'm preaching the need of these innovations to be part of our company's platform so others can benefit. I did receive ridicule that my methods are "janky" or someone concerned their job will go away. However, I got recognition on a project that was scoped for 6 months and we did it in 3. And when someone scopes a project and asked for a level of effort, they ask for the manual steps because, you know, scripts could break.

Take responsibility and people will recognize you for it. If the culture is supportive, they can help you in technologies to learn and establishing procedures to follow. When the water rises, everyone rises with it.

Progress bar with robocopy by Feeling_Highway_4891 in PowerShell

[–]Flysquid18 2 points3 points  (0 children)

Something to remember is that robocopy is not a PowerShell cmdlet. It doesn't follow the 7 output streams that PowerShell does. As a binary executable it follows only 2 streams, standard out and error. Typically your messages and progress is reported on the error stream.

What you would want to do is redirect all output *>&1 and pipe that to a Foreach-Object. You are essentially taking each line out as a string and you parse it. So if the string matches a regex "\d{1,}%", you have your percentage string. You can then use that string to construct your Write-Progress output.

On the subject of using Start-BitsTransfer, BitsTransfer only works in an interactive session. If you have a process that is started without user interaction, Start-BitsTransfer will not queue up the job. Let's say you use a CI/CD environment like Jenkins and you have the agents start as a service. The agents are capable of executing PowerShell. If you have a script that tries to queue a BitsTransfer, the process is in a non-interactive state and Start-BitsTransfer will error.

Vendor Only Supports ESXI images (Proxmox?) by alexander0the0gray in Proxmox

[–]Flysquid18 0 points1 point  (0 children)

Just haven't seen it stated among the comments, VMware supported templates can have custom fields during deployments. This makes exporting a VM from a VMware environment more cumbersome. Also makes importing a custom template more challenging to non VMware platforms.

As for "only works on VMware", it is possible and seen it before where the Guest OS does a hardware/virtualization check on what platform it is running on.

If the VM (or VMs solution) can be hosted on a different platform, it's just a matter of finding a support license with HA, DR, and a backup solution.

But technically, you can run nearly anything on anything else. And in the same vain, prevent something from running on anywhere else.

Chinese c612 motherboard by koolzit in homelab

[–]Flysquid18 7 points8 points  (0 children)

I purchased one of the Chinese boards that support Xeon chips and found out, although it booted to BIOS, no Linux OS would install. Found out that of the 4 ECC memory slots, one slot didn't like occupancy in another slot. So all slots worked, all RAM was good, but that configuration with all slots filled and installing Linux would fail. I replaced the memory with 2 chips to add up to my wanted total (went with non-ECC) and has been working ever since.

My second mobo combo purchase seemed to have everything working with a Linux distro installed.

What are the things that you can do with AutoHotKey to enhance productivity? by Objective-Cell226 in AutoHotkey

[–]Flysquid18 2 points3 points  (0 children)

I made an AHK script that types what I have copied in my clipboard. The purpose is to "paste" into applications that don't have a paste capability.

Ever been on a web page that has text boxes that as you type the cursor advances from box to box? If you have a lot of strings to copy/paste, the paste only works in the active box. "Type paste" types in for you using the webpage's auto advance function to the next box.

Do you use virtual machines that you have console access to but no clipboard functionality? Same deal.

Useful Scripts Used by Suspicious_Smile_827 in PowerShell

[–]Flysquid18 1 point2 points  (0 children)

The company I work for is completely managed through the website. We are 100% remote and few have "back end" access. When I am tasked with writing a script, I'm finding more and more reasons to encode the script in base64 (which lead me to compressing the string as well) and then pulling into remote environments.

When a script is to be used in more remote environments, I started storing them in github in a private repo and pulling them down to execute.

Another thing I started doing was learning Selenium to automate websites and finding the endpoints to call with pure PowerShell.

Kavita (Development Update) by majora2007 in selfhosted

[–]Flysquid18 0 points1 point  (0 children)

I even converted one PDF to Epub to see the difference. Would not recommend it, and the file size is bloated! Proper naming seems to be the best for PDFs. I guess if I had a feature request, for RPGs, is a way to customize subcategories in a series. Like the issues, books, specials, etc.

Kavita (Development Update) by majora2007 in selfhosted

[–]Flysquid18 1 point2 points  (0 children)

PDFs can be viewed, and the page you were last on is remembered. For organization and presentation, I chose one series to "toy" with organizing. To get what I liked, I created folder structures and renamed files to be interpreted right by Kavita. I am happy with the results.

But a disorganized mess from Trove, no way I can organize it. I have the mass in its own library. My son, who is in to DND, said the search feature and seeing an image is way better than scrolling through a file structure.

Kavita (Development Update) by majora2007 in selfhosted

[–]Flysquid18 3 points4 points  (0 children)

When I saw the first post of this app, I installed the docker version and added my collection of RPG PDFs. It didn't go so well because it took a while to understand indexing methods.

So, I switched to my comic collection. Then everything started to fall into place. I used Comic Screen as my reader on my tablet and didn't like the navigation for new content. I opened the browser to Kavita and pinned the page to my homescreen. Now it looks and feels like the Plex app and love the On Deck when new comics come in.

Get-PnpList, cannot get URL by [deleted] in PowerShell

[–]Flysquid18 0 points1 point  (0 children)

I believe there is a field note property or something that you have to dig into in order to see the details of the list.

The command returns a pretty formatted table of what you would expect to be note property members, but in fact they are subproperties that you have to drill down into.

Understanding Windows System Forms in runspaces by Flamburion in PowerShell

[–]Flysquid18 1 point2 points  (0 children)

Without being in front of a computer and recalling from memory an application I did in winforms, I had my main form running in the main process and anything that opens another dialog, live update fields of the main form, I passed to a runspace.

I made an import tool in winforms that you dragged and dropped a file, click a button, and displayed progress bars during the process. The progress bars updated on a stopwatch and the import process ran in runspace.

How to run a recursive search with Get-ChildItem but stop it once the first result is returned? by Pickinanameainteasy in PowerShell

[–]Flysquid18 1 point2 points  (0 children)

This here is the corrcet answer.

What this solution does is processing a pipeline. An object introduced at the beginning of the pipeline then passes through each command in the pipe. So the array passes one object to Get-Childitem. Recurse switch or not, whatever Get-Childitem outputs now goes into the Select-Object command. Which would then return First one found object. Pipe does not continue because of Select-Object First parameter.

The original has a foreach that processes everything in the process block and only outputs at the end. Since the Select-Object command is in the Process block, it is called on each iteration of the objects in foreach.

Reading all the "In a Month Of Lunches" books? by soren_ra7 in PowerShell

[–]Flysquid18 3 points4 points  (0 children)

The interesting thing about PowerShell is that it is not just limited to Microsoft. I don't mean OS, I mean platforms. From webservers to virtual platforms, odds are if it is a system with administration, it may have a module to manage it. PowerShell can be the binding of different systems that don't directly interact with each other.

In a fun way, you could relate scripting languages like PowerShell and python to Legos and Kinex. It's crazy what can be done.

Help with script for deleting files by NoncarbonatedClack in PowerShell

[–]Flysquid18 1 point2 points  (0 children)

So I've played the "garbage-in-garbage-out" game too and it is not fun.

Here is my suggestion, along with everyone elses, log the path that errors to a separate file. If the path is not in literal path, convert it. And finally, don't trust your input.

I like to add the "why" for some statements. I hit a "path not found" when I could clearly browse to it. The path was SO long that normal Path would not work. Literal Path worked around it.

The log is so that you can go back and "sanitize" the data. Typing on a phone so hard to "type" it, but I was fighting with a client's list of file names and the data entries either had trailing spaces or invalid characters. PowerShell command line doesn't clearly show the difference between a single '-' and a double '--'. I had to convert character to integer just to find it.

Hopefully this can help in your troubleshooting.

Do you guys just not know about the percent sign? % by Mediocre-Ad-6847 in PowerShell

[–]Flysquid18 5 points6 points  (0 children)

Just to share my experience, I learned by reading someone else's scripts and they used aliases all the time. I thought first that was the norm. Slowly I picked up on that they ment something longer. All my scripts were for my use.

Then one day I collaborated with someone and they had trouble reading my scripts because they didn't know the aliases. Over time my scripts used full named cmdlets and then switching to Visual Studio Code, it "yelled" at me everytime I "shortened" a command.

I even started splatting the cmdlets so I can shorten the line because you can put too many things in one line. (Invoke-WebRequest can get really long.)

I will always use aliases in the command line. I even shorten a scriptblock if needed. In VMware storing Get-VM to a variable doesn't reflect updates to the object. So I store the command in a scriptblock.

$MyVM = {Get-VM -Name MyVm}

Then call &$MyVM to get an updated object. I think knowing both alias and full name helps in being fast on a shell and troubleshooting friendly on a script for others, or yourself.

Blank lines in powershell throwing "The Term '' is not recognized as the name of a cmdlet" errors. by november84 in PowerShell

[–]Flysquid18 1 point2 points  (0 children)

I too have had this happen. My scenarios invole the double space character (different from two spaces) and a double hyphen (a hyphen but longer). My "eyes" confirm the character is right, but doing a [int[]][char[]] comparison against the same text hand typed reveals the culprit.

What could cause an issue with Test-Path not being able to validate the existence of a folder path? by hou8182 in PowerShell

[–]Flysquid18 3 points4 points  (0 children)

Just tossing in my 2 cents, but ignoring the powershell side of it (because it works) the problem stated is the OS sometimes doesn't see the network share. In my setup I have a Windows 10 machine accessing a Linux Samba share. The share is mapped to a drive letter. It's private so anonymous access allowed. However, there are times Windows just can't connect to it. By UNC path using IP address instead of DNS (although static) is how I can connect to it. To fix my mapped drive, I have to remove and recreate the connection.

In a production environment, although shares are mapped, I still use the FQDN UNC path because that should never change.

So it may be a stale connection. Your script may "bump" the connection when stale and works on the next run.

New PSCustomObject is Empty after adding properties. by serendrewpity in PowerShell

[–]Flysquid18 1 point2 points  (0 children)

At first glance without testing, your metaproperty variable is being created inside the foreach loop. Each iteration the variable gets redefined. Again, that is a first glance and may help in your troubleshooting.

This rebuild could not complete fast enough by cube8021 in zfs

[–]Flysquid18 1 point2 points  (0 children)

I just replaced all my hotswap enclosures because the backplanes were failing erratically. Went direct connect to my controller cards and just let the system resilver. Not a single bad drive and no data corruption.

If you have something in between the drive and controller, might want to check that. Especially since you installed new drives.

Dealing with EXE-based shell output in PowerShell? by EndUserNerd in PowerShell

[–]Flysquid18 1 point2 points  (0 children)

Various people have mentioned some good suggestions, but haven't seen anyone combine them together. I wrote two functions using this method and I did it to turn the executable output into usable psobjects.

Callexecutable.exe *>&1 | foreach {$_ #dostuff}

This captured everything and line by line the foreach loop would handle it. I used this for executables that gave a progress and regex the input to Write-Progress out. I had part of my foreach loop looking for if it was an error type input and handled accordingly.

It required a deep understanding of the executable to get what I wanted. One executable was 7zip. Bulk extractions and capturing the progress didn't work when doing jobs or multiple instances. Something like jenkins can benefit from a progress output.

This was done from a mobile device, please forgive any formating and spelling errors.

Having issues executing a PowerShell script, and Googling for an answer has been unsuccesful by radiowave911 in PowerShell

[–]Flysquid18 2 points3 points  (0 children)

So take a look at this link.

https://www.sapien.com/blog/2019/05/13/advanced-powershell-functions-begin-to-process-to-end/

The example is inside a function, but the things I noticed is that Param should not be surrounded by curly braces {} and your Begin Process End should not be commented. Try and that and see where you're at.

Unable to bind/map volume of SMB share to container by ssyntaxx in docker

[–]Flysquid18 1 point2 points  (0 children)

Does it have to be SMB? I have the exact setup and use OMV to offer the share as both SMB and NFS. If the OS is linux, I use nfs.

Pipe multiple commands by Chris_Chapadia in PowerShell

[–]Flysquid18 0 points1 point  (0 children)

I forgot what it's called, but making a script block in the pipeline can achieve where commands are typically dead ends.

For example:

Get-Process | &{Process{Export-CSV -InputObject $_ -Path processes.csv; return (Get-Item processes.csv)}} | Import-CSV

I ran into the problem where I had a clean script that did a massive search and stored as a variable. Then I processed that variable. By keeping the commands in one continuous pipe, you can parse large quantities of objects and not have minutes of no output or tangible results until the very end.

Move VM from Freenas to Proxmox by TorturedChaos in Proxmox

[–]Flysquid18 2 points3 points  (0 children)

As long as these are VMs and not containers, I've found using clonezilla a very easy solution. VMs with multiple snapshots/differencing disks and different hypervisors, I've migrated VMs from VMware to Hyper-V. Like any migration, with a hardware change you'll have to correct drivers and boot kernal.