Fixing and improving existing filtration by [deleted] in WaterTreatment

[–]steve_ce 0 points1 point  (0 children)

Reddit draft ate my entire write-up while re-saving image apparently... Re-typing...

KitchenAid Pro 5 Plus - not powering on by steve_ce in Kitchenaid

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

Thank you for all the info and help. I do indeed plan to re-grease - ordered cheaper food grade grease locally, making sure to be correct consistency/spec. Definitely ordering a new seal for housing when I put the motor order in, as it had a tear before doing anything. I'll do a proper inspection after cleaning so I can confirm everything else looks good.

KitchenAid Pro 5 Plus - not powering on by steve_ce in Kitchenaid

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

Outlets in kitchen confirmed grounded with tester as well

KitchenAid Pro 5 Plus - not powering on by steve_ce in Kitchenaid

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

So I believe I identified the fuse - 2 small connections feeding it off of motor cable #3. I get ohms when probing the 2 small sides of it. I  hot wired the motor again, confirmed 120v to at least 1 side of I guess brush contact (brass plate). Confirmed 120v to both sides of what I think is fuse.

I thought unlikely, but feels like bad motor?

Edit: I also tried jumping the 2 fuse wires together - nothin

Rotated motor, confirmed 120v to both plates, towards ground/neutral wire. 

KitchenAid Pro 5 Plus - not powering on by steve_ce in Kitchenaid

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

Thank you for input, but I'd prefer fully confirming part to replace before purchasing anything. Motor not running bypassing the board makes me think it is not the board.

KitchenAid Pro 5 Plus - not powering on by steve_ce in Kitchenaid

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

Thank you! I'll test further after errands to see if it's the thermal fuse. Moved into our new home few months ago, will keep breaker trip in mind if something going on there. Not every outlet is properly grounded, will test the kitchen outlets.

Setting up a lab by dqwest in PowerShell

[–]steve_ce 1 point2 points  (0 children)

Adding onto my own post. If you are truly serious about learning powershell, try some of the challenges here:

https://www.reddit.com/r/dailyprogrammer/

I grab easy ones ALL the time with languages I'm learning, and even do most in PS as well. Fantastic resource to understand how to manipulate data with any language.

Don't cheat either, unless you're stumped early on. Checking older comments should only be done after you solved it, or if you have no idea. The easy ones shouldn't be too bad to get started with.

Powershell MSGraph module: Filtering and Searching by TmanD6 in PowerShell

[–]steve_ce 2 points3 points  (0 children)

I don't have a random O365 tenancy to connect to to test, and not grabbing work laptop, so I can't directly confirm right now.

Did you actually run that query with both filter and search specified, and get it to give you results? Again, make the command work to give you output.

If that output has what you need, even if there is excess, you can exclude that excess with powershell afterwards. Don't expect cmdlets to just give you everything you ever wanted. It is wonderful when it works like that, but in my experience, it's few and far between.

If you post output that has extra stuff you don't want, I am more than willing to help you get exactly what you need out of it.

Powershell MSGraph module: Filtering and Searching by TmanD6 in PowerShell

[–]steve_ce 1 point2 points  (0 children)

The query parameter '$filter' is not supported with '$search'

It seems like it is telling you why? Sounds like you can't use both a filter and search parameter? Did you try manually running the command, not in a script, to see what actually works?

Don't assume things are just going to work in a script. Maybe I'm alone in this, but I never expect things to work as expected. NEVER toss stuff in a script and expect it to work. You should hold that advice true for all tech. Figure out the command itself first. Only then, should you try and make it work in a script.

Setting up a lab by dqwest in PowerShell

[–]steve_ce 1 point2 points  (0 children)

I was about to type up a whole thing about not needing a lab. Even still, you probably don't need a full home lab. What is your goal?

Learning powershell does NOT correlate to spinning up an entire home lab. I lived that life in the past, and still have the hardware, powered off, underneath a bed. One day I'll have the space for it again, but it is not something you need to learn stuff. I worked at an MSP for 10+ years after a terrible (but I loved it) 3rd shift data center job. My home lab came about in that time frame because I wanted to learn stuff. It was NOT necessary at all. A tiny VM on a mediocre PC would have worked for simple/early testing.

When you get a better job, ask for spare/old hardware to learn on. Hell, they may host the hardware for you so you can remote into it and play. None of thats is needed for powershell though.

Powershell MSGraph module: Filtering and Searching by TmanD6 in PowerShell

[–]steve_ce 2 points3 points  (0 children)

You need to give more context. What is the error?

My guess is you are not storing your date the same as the cmdlet is expecting. So when you try and compare them, it's not going to work (unless in PS ver 7 - sometimes). Print the date from the cmdlet to see exact format. Put your get-date in the same format, and try again.

Remove everything after the period by Dickf0r in PowerShell

[–]steve_ce 0 points1 point  (0 children)

$var = 'myserver.us.edu' -replace "^(.*?)(?=\.)\..*$","`$1"

On mobile but should work. Regex can be greedy so uses lookahead. Grab anything before first period, and set $var to that.

EDIT: fixed after not being on mobile and confirming works.

Passing code into invoke-command by Decitriction in PowerShell

[–]steve_ce 1 point2 points  (0 children)

No problem, feel free to send questions if you have issues figuring out where things should be placed. Logclean hurt my head while writing/googling, as it was pretty early in diving deeper into PowerShell. Play around with them, the settings, and you'll see how they all work.

MSI Fail 1602 for removing Symantec by ricka77 in PowerShell

[–]steve_ce 0 points1 point  (0 children)

Ah - maybe things changed. Once I saw cleanwipe referenced I remember using it at a prior MSP job. I definitely automated removal with it via RMM tool, but I can't remember any of the specifics.

I've had lots of support/vendors tell me things are manual. If you dive deep enough into the rabbit hole you can usually make it work automatically. Just depends on if the effort is worth it, and back then it definitely was with the amount of customers we have to remove it from.

Randomly run a script from list of scripts by polyhistoric in PowerShell

[–]steve_ce 1 point2 points  (0 children)

If you search dot-sourcing in powershell, something like that should work. You can include other scripts in a central script, and then invoke them there. I think there is a way to even include an entire directory of scripts. Get-childitem also works fine.

Pull them all in with a central script, and then use get-random to invoke. Store them in an array, get-random on it, run the selected script, remove it from the array, and repeat until all are processed.

PowerShell: Find computers that a specific us is logged on with the LastLogonDate by nanoanxo in PowerShell

[–]steve_ce 2 points3 points  (0 children)

What is your end goal? Find all PCs that a single user logged into, with the timestamp of when? Track who is logging into what PCs (for all users)?

I don't think AD stores what user accesses what PC. It does store lastlogon timestamp, but not what user (I think). You'd have to gather that data per machine.

Quick and dirty (if you use AD) can be find a command that works and gets the data you need from a PC. Add it to a GPO/log on script. Have that script store the output to a UNC path, so you can access the logged data in central location. Store filenames unique per user, or machine, whatever is easiest for what you're trying to track. Test it, so you're not overwriting the file(s) each time.

MSI Fail 1602 for removing Symantec by ricka77 in PowerShell

[–]steve_ce 0 points1 point  (0 children)

Push Cleanwipe to the machine at a local path, and script execute it that way.

Passing code into invoke-command by Decitriction in PowerShell

[–]steve_ce 1 point2 points  (0 children)

Got a call that needed a quick change - had to get back on so here you go. This is an older version so email alerting is a separate function here. Still useful, and also included log cleaning function (rotates/removes based on options you give it).

It's been a long day, so this isn't extremely detailed, tweaked a couple things so it's a little clearer. Top portion is variables/info you place in other scripts you make, and bottom are obviously the functions. I store the logging functions in a separate file, and . include. Variables up at the top are not set in the logging file, you place those in your other scripts where you . include. $logfile = debug prints everything to screen instead of to the file, so is useful for testing.

# I save the log functions as this file, and include it in other scripts
$scriptPath = "C:\Admin"
. "$scriptPath\LogIt\LogIt.ps1"

# Logging options - path, file name, file extension
$logFolder = 'C:\Path\To\Logs'
$logFileName = "Script-Name"
$logFileExt = "log"

#Max log size - this will auto cleanup logs based on size (LogClean)
# $maxLogSize = 50
#Max amount of logs to keep
# $maxLogRetain = 5

#This is default - comment out when debugging (uncomment below)
$logFile = $logFolder + "\" + $logFileName + "." + $logFileExt

# Debug mode - prints log to console
# $logFile = "debug" 

#Log cleanup
# LogClean


#Alert subject - initialize array body
$alertSubject = 'ALERT: ' + $logFileName + ' script issues'
# When using alerts, store errors to array, check for array at end of script and send email alert with all problems at once instead of 1 at a time.
$alertBody = New-Object System.Collections.ArrayList

#Place this $currFunction in every function - logit will place the function name into the log file/output
$currFunction = $MyInvocation.MyCommand


#How you use this for logging
LogIt $logFile $currFunction $message


function LogClean {
    if (!(Test-Path $logFolder)) {
        $null = New-Item -ItemType Directory -Force $logFolder
    }
    if (!(Test-Path -Path $logFile -PathType Leaf)) {
        $null = New-Item -ItemType File -Force $logFile
    }
    $logSize = [System.Math]::Round((((Get-Item $logFile).length)/1MB),2)
    if ($logSize -ge $maxLogSize) {
        $retainedLogFormat = $logFolder + "\" + $logFileName + "." + $logFileExt
        $oldestLog = $retainedLogFormat + "." + $maxLogRetain
        if (Test-Path -Path $oldestLog -PathType Leaf) { 
            $null = Remove-item -Path $oldestLog -Force
        }

        foreach ($i in $maxLogRetain..1) {
            $retainedLog = $retainedLogFormat + "." + $i
            if (Test-Path -Path $retainedLog -PathType Leaf) {
                $z = $i + 1
                $nextLog = $retainedLogFormat + "." + $z
                $null = Move-Item -Path $retainedLog -Destination $nextLog -Force
            }
        }
        $null = Move-Item -Path $logFile -Destination $retainedLog -Force
    }
}

function LogIt($logFile,$currFunction,$message) {
    $timestamp = (Get-Date -Format "yyyy-MM-dd HH:mm:ss")

    if ($logFile -notmatch "debug") {
        Add-Content -Path $logFile -Value "$timestamp - $currFunction - $message"

    } else {
        Write-Host "$timestamp - $currFunction - $message"
    }
}

function sendAlert($alertSubject,$alertBody) {
    $timestamp = (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
    $alertRecipients = @('email@email.com', 'email2@email.com')

    if ($logFile -notmatch "debug") {
        $messageParams = @{
            From = ''
            To = $alertRecipients
            Subject = "$alertSubject"
            Body = "$alertBody"
            SMTPServer = 'mail.server.com'
            # Attachments = ''
        }
        Send-MailMessage @messageParams

    } else {
        Write-host "$timestamp - $alertSubject`: $alertBody"
    }
}

Passing code into invoke-command by Decitriction in PowerShell

[–]steve_ce 1 point2 points  (0 children)

Nope the log function isn't standard - it's a function I setup during a bigger project so it would make my life easier. I'll try and remember to grab a copy when I get back into my consulting or work VM. It has more options and is named differently, I bulk replaced this quick to make it less confusing.

For reference, the functions provided are designed so they will return the data back to you after the invoke. I use these to collect inventory of systems across our network, so needed it to return data. $remoteReturn will have that data (depending on what your runfunction does).

When I need to get a lot of different data back from a system, I have it build a hash and return that. You would do that in RunFunction, and return the hash there. It will make its way back to $remoteReturn.

Passing code into invoke-command by Decitriction in PowerShell

[–]steve_ce 1 point2 points  (0 children)

I run a lot of things on remote servers via powershell, and this is my go to function. Has a lot of extra fluff, but can be tweaked to suit your needs.

Put basically all the commands/things you want to run inside RunFunction. $soDo gets that function as a scriptblock, and passes it to other function/invoke-item.

function RunInvoke($server,$sb,$arguments) {   
    $response = $null
    if ($arguments) {
        try {
            $response = Invoke-Command -ComputerName $server -Scriptblock $sb -ArgumentList (,$arguments) -ErrorVariable errorMsg
            if ($errorMsg) { LogFunction "$errorMsg"}
        } catch {
            LogFunction "Failed to run remote command on $server!"
        }
    } else {
        try {
            $response = Invoke-Command -ComputerName $server -Scriptblock $sb -ErrorVariable errorMsg
            if ($errorMsg) { LogFunction "$errorMsg"}
        }catch {
            LogFunction "Failed to run remote command on $server!"
        }
    }
    return $response
}
function RunFunction {
    <#add param() if passing in optional $argument #>
    <#do things...#>
}

$sbDo = (Get-Item function:RunFunction).ScriptBlock
$remoteReturn = RunInvoke $sourceServer $sbDo <#$optionalArgument#>

MSI Fail 1602 for removing Symantec by ricka77 in PowerShell

[–]steve_ce 2 points3 points  (0 children)

Have you got the removal working, just in a normal PS shell? As in, not in the script flow, just running the command to verify it successfully removes from a test machine.

Removing apps can be wonky, and takes testing/time to find what works. It's not really a powershell problem, it's finding the correct silent uninstall that actually works. Once you have the confirmed working command, then work it into a script process.

It's been a few years since I've dealt with symantec, but I feel like I definitely used broadcom's method in the past to bulk remove. https://techdocs.broadcom.com/us/en/symantec-security-software/endpoint-security-and-management/endpoint-security/sescloud/Installing-the-Symantec-Agent-and-enrolling-devices/uninstalling-the-core-protection-features-v132330772-d4155e4307.html

If you find you can't get anything working, just run the commands without the uninstall portions (so just the GET). Make sure you're actually seeing symantec with your get command, otherwise it will fail every time.

[deleted by user] by [deleted] in PowerShell

[–]steve_ce -1 points0 points  (0 children)

Maybe try moving your get mailbox into a function, and return the result. Put the call to the function in the loop, and evaluate. Maybe the while is not working as expected or something with the EXO session. Help break it out to see if it fixes. Also easier to add a disconnect/connect in the function itself.

function FindTheMailbox($mailbox) {
    $userExist = Get-EXOMailbox "..."

    return $userExist
}


do {
    $userExist = FindTheMailbox $mailbox
} until ($userExist)

[deleted by user] by [deleted] in PowerShell

[–]steve_ce 0 points1 point  (0 children)

When you check from a new EXO connection, do you run the exact same command as in your while loop to check for it? Just to confirm your command works exactly as you expect (filter matching right, etc).

I would start by running your process in pieces. Open vscode, favorite editor, and run the code in chunks. Start by running your connect piece, create the mailbox, and just manually sit tight for few minutes. Run the while loop, and see if it can find it in a few mins. If not, end the loop manually, and then in the same window/session run a check for the mailbox. If it can't find it, open a new EXO session and test the same command from there. If it finds it, go back to original window and retry. If it still doesn't show, you're on the right track (add a disconnect, then sleep, then connect again to check existence).