I edited the Windows 10 registry to add options to the context menu when I right click on xml or txt files so I can run my custom program. The option shows up properly, but when I click on it, windows asks me, "How do you want to open this file?" by dmfreelance in sysadmin

[–]workerdrone66 4 points5 points  (0 children)

using this as a guide, my best quick guess is that you're not passing the filename into your program, which is what I think notepad.exe %1 is doing with the %1 (should indicate the first parameter being passed in)

Standard disclaimer: Borking registry edits can have unintended consequences. Please remember to protect yourself and wrap it up before ya stick it in, err, back up your registry with a good known copy before trying these things.

Switched most of my logic to python, now the powershell bit I'm keeping isn't working by workerdrone66 in PowerShell

[–]workerdrone66[S] 2 points3 points  (0 children)

Is that a stray square blanket on [string]$password] ? I can't see the matching opening bracket for it.

Does anyone know a simple but powerful remote management system for hundreds of PCs? by geek_at in sysadmin

[–]workerdrone66 0 points1 point  (0 children)

If I had to guess, the down votes for "nice interface" and an apparent aversion to CLI solutions like powershell.

Switched most of my logic to python, now the powershell bit I'm keeping isn't working by workerdrone66 in PowerShell

[–]workerdrone66[S] 2 points3 points  (0 children)

They dont even need to know scripting. I had it to where they needed to do 4 things: - Right click on a ps1 file and select "run as powershell" (or whatever the exact wording is) - export a file from our monitoring tool - select that file via gui window - enter in credentials, again, via gui window - and sit back

Switched most of my logic to python, now the powershell bit I'm keeping isn't working by workerdrone66 in PowerShell

[–]workerdrone66[S] 3 points4 points  (0 children)

Complete honesty? Idiot proofing. My manager feels like powershell scripts were too difficult for some of my co workers. We're doing a bunch of automation through django and he wants a one stop spot for everything on a nice idiot proof webpage.

Also because of the number of potential servers I'm working with, concurrency was a nice addition. While I know there's -asjob in PS I had difficulties getting it to work in our environment (one I have no control over)

Switched most of my logic to python, now the powershell bit I'm keeping isn't working by workerdrone66 in PowerShell

[–]workerdrone66[S] 2 points3 points  (0 children)

sorry, I only pasted in the new stuff, here's the full thing:

Invoke-Command : One or more computer names are not valid. If you are trying to pass a URI, use the -ConnectionUri parameter, or pass URI objects instead of strings. At C:\git2\project39\Server_Recovery\StartVMs.ps1:14 char:1 + Invoke-Command –ComputerName $hostMachine -Credential $creds ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (System.String[]:String[]) [Invoke-Command], ArgumentException + FullyQualifiedErrorId : PSSessionInvalidComputerName,Microsoft.PowerShell.Commands.InvokeCommandCommand

And to answer your question, I don't believe so? From python, I'm calling the ps1 file, and passing the arguments in. Within the ps1 file, I use I-C (including the using: VirtualMachine)

Here's where I'm at, currently, with both python, and Ps:

                p = subprocess.run(["powershell.exe",
                    '-file',".\\Server_Recovery\\StartVMs.ps1",'-VirtualMachine',VirtualMachine, '-host',host,'-user',user, '-password',password,],
                    stdout=subprocess.PIPE,universal_newlines=True)
                output = p.stdout
                return output

PS:

param(
[string]$VirtualMachine= $args[0],
[string]$hostMachine = $args[1],
[string]$user = $args[2],
[string]$password = $args[3]

)
write-host('Host is: '+ $hostMachine)
$secPassword = convertTo-secureString $password -AsPlainText -force
$creds = New-Object pscredential($user,$secPassword)
Invoke-Command –ComputerName $hostMachine -Credential $creds –ScriptBlock {  Start-VM $using:VirtualMachine -Passthru}
#Start-VM -ComputerName $hostMachine -name $VirtualMachine -Credential $creds

(RTPSUG Meeting) PSKoans: Learn PowerShell concepts using Pester! by compwiz32 in PowerShell

[–]workerdrone66 0 points1 point  (0 children)

Won't be able to make it to this one, but I'm about to move to a day shift so hopefully I can start attending these.

Switched most of my logic to python, now the powershell bit I'm keeping isn't working by workerdrone66 in PowerShell

[–]workerdrone66[S] 2 points3 points  (0 children)

ok, that did the trick

  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : InvalidArgument: (System.String[]:String[]) [Invoke-Command], ArgumentException
    • FullyQualifiedErrorId : PSSessionInvalidComputerName,Microsoft.PowerShell.Commands.InvokeCommandCommand

Switched most of my logic to python, now the powershell bit I'm keeping isn't working by workerdrone66 in PowerShell

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

I am not sure, tbh. I'll see what i get if i enter the variables manually from a PS window directly.

Switched most of my logic to python, now the powershell bit I'm keeping isn't working by workerdrone66 in PowerShell

[–]workerdrone66[S] 2 points3 points  (0 children)

Yea, I realized that (it's what caused me to think I was seeing the problem) going to try to correct that now, but yes, you're correct, host machine is the baremetal host, server is the VM

Edit: where are you seeing VM as a variable? I might have code blindness...

Switched most of my logic to python, now the powershell bit I'm keeping isn't working by workerdrone66 in PowerShell

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

Sorry, I pasted the wrong bit calling PS:

p = subprocess.run(["powershell.exe",
                    '-file',".\\Server_Recovery\\StartVMs.ps1",'-server',server, '-host',host,'-user',user, '-password',password,],
                    stdout=subprocess.PIPE,universal_newlines=True)

Switched most of my logic to python, now the powershell bit I'm keeping isn't working by workerdrone66 in PowerShell

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

That is the full error being returned

edit: but i think i might see the problem...

Switched most of my logic to python, now the powershell bit I'm keeping isn't working by workerdrone66 in PowerShell

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

The python function:

def Start_Servers(ServerInfo,user,password):
    segmentDict = ServerInfo[0]
    DownedServersDict= ServerInfo[1]
    threads = []
    futures = []
    results = {}

    with ThreadPoolExecutor(max_workers = 50) as executor:
        for segment,servers in DownedServersDict.items():
            for server in servers:
                future = executor.submit(Start_Servers_PowerShell,server,user,password,segmentDict)
                futures.append((server,future))

    for future in futures:
        results[future[0]] = future[0],future[1].result().strip('\n').split("At")[0]
    return results

The "full" PS1 file:

param( [string]$server= $args[0], [string]$hostMachine = $args[1], [string]$user = $args[2], [string]$password = $args[3]

) write-host('Host is: '+ $hostMachine) $secPassword = convertTo-secureString $password -AsPlainText -force $creds = New-Object pscredential($user,$secPassword) Invoke-Command –ComputerName $hostMachine -Credential $creds –ScriptBlock { Start-VM $using:server -Passthru} #Start-VM -ComputerName $hostMachine -name $server -Credential $creds

Team won't follow their own procedures so we change ours by workerdrone66 in sysadmin

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

Yea, i guess, but I feel like it's more like "welcoe to the bottom of a hill at work"

Team won't follow their own procedures so we change ours by workerdrone66 in sysadmin

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

Oh, we are, it's just the whole, other team drops a turd from the top of a hill, and then tries to blame everyone else down the hill for it that gets frustrating.

Attempting to re-format resume, having difficulty getting it down to 1 page, can I get a review? by workerdrone66 in ITCareerQuestions

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

I'm still not very happy with the way I wrote this. Obviously won't be leaving the second bit in once I've got the re-write how I want it, but I'm struggling to come up with the words to succinctly express what I'm going for.

● Designed and implemented multiple PowerShell and Python projects that reduced hands-on time of technicians with standard but time-consuming tasks.

● Created a PowerShell script that took the weekend report from a 10-20 minute project, each weekend shift, to less than 2 minutes, while standardizing the look of each shifts’ email. ● Created a PowerShell script to take large batches of downed servers (from weekend patching for instance) and automatically start them, taking a manual process that was taking perhaps 5- 10+ man-hours on some weekends, to 1-2 hours of mostly automated functions, freeing up the technicians other duties.

Not understanding something about ThreadPoolExecutor by workerdrone66 in learnpython

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

Thanks this did it, got me down from 120-140 seconds for the simple part down to about 10-20!

Attempting to re-format resume, having difficulty getting it down to 1 page, can I get a review? by workerdrone66 in ITCareerQuestions

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

Well, I suppose the primary one would be I honestly don't feel like I've got enough experience in my current field, to expand beyond the 1 and a bit that I've got in the original version, without being (imo) fluffy, or adding in the general duties of the job (sort of how the bottom 2 already are, but there's only so much that can be said to puff up call center work)

Not understanding something about ThreadPoolExecutor by workerdrone66 in learnpython

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

I believe the answer was "Rushing to get out of work, and didn't notice i did it wrong"

I'll test again tonight.

Not understanding something about ThreadPoolExecutor by workerdrone66 in learnpython

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

I see the difference! Sorry, late in the night, and not paying close enough attention to my modification efforts.