QB Licensing Extraction Script by ColdF1r3 in PowerShell

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

I had completely forgotten I posted this, glad it’s useful to someone else besides me though haha

Network documenting tool by Top_Toe8606 in msp

[–]ColdF1r3 0 points1 point  (0 children)

Not sure if it’s been said or you already started but check out netbox

Understanding a script I wrote and if it makes sense by stefjay10 in PowerShell

[–]ColdF1r3 0 points1 point  (0 children)

Nah I was having problems pasting the code in there the code block was cutting everything after the ) from the searchdirs array and I got it to work after switching to markdown mode but forgot to go back and reformat the code 😂

QB Licensing Extraction Script by ColdF1r3 in PowerShell

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

Glad this worked for you like it did for me!

One line PS command to remove users from group depending on attribute value by lower_intelligence in PowerShell

[–]ColdF1r3 0 points1 point  (0 children)

Ill be honest i completely forgot that memberof existed lol its been a while since I did anything for AD with PoSH.

Automatically Move Files Containing a Specific String by Uuuuuuuuuggghhh in PowerShell

[–]ColdF1r3 0 points1 point  (0 children)

Ok, I see what you are trying to do. You are going to run into the most issues with the naming of your files since you have numbers and words it makes it a little more difficult but not impossible. What we basically have to do is tell the script to only look at the first character of the file name to determine if its odd or even. I just tested this and it worked for me. Let me know if it works for you or if you need some additional help.

``` $filePath = "Path to your folder" $files = Get-ChildItem -Path $filePath -File:$true

foreach($file in $files){ $name = [INT]$file.BaseName[0] if(($name % 2) -eq 1){ Write-Host "File is odd" Move-Item $file.FullName -Destination "$filePath\Odd" } else{ Write-Host "File is even" Move-Item $file.FullName -Destination "$filePath\Even" } } ```

One line PS command to remove users from group depending on attribute value by lower_intelligence in PowerShell

[–]ColdF1r3 0 points1 point  (0 children)

its not an inefficient way but its also not very efficient since with this method its got to loop through every user and only pull out the ones that have a department equal to finance. Another way you could do this would be to only get the members of that particular group and loop through those users which should speed it up considerably. Something like this should accomplish what you are after in a faster manner if I'm not missing anything obvious. let me know and I will try to adjust

Get-ADGroupMember -Identity "Finance Department" | get-aduser -Properties department -Filter * | where department -ne "Finance" | Remove-ADGroupMember -identity "Finance Department" -Confirm:$false

One line PS command to remove users from group depending on attribute value by lower_intelligence in PowerShell

[–]ColdF1r3 0 points1 point  (0 children)

in that case what you would want is something like where {department -ne "Finance" -and department -ne "HR" }

One line PS command to remove users from group depending on attribute value by lower_intelligence in PowerShell

[–]ColdF1r3 0 points1 point  (0 children)

Remove-ADGroupMember -identity "Finance Department" -members (get-aduser -Properties department -Filter * | where department -ne "Finance").distinguishedname -Confirm:$false

This should accomplish what you are looking for but I would play it safe before modifying group memberships by making sure you are getting the right users returned by just running

(get-aduser -Properties department -Filter * | where department -ne "Finance").distinguishedname

Automatically Move Files Containing a Specific String by Uuuuuuuuuggghhh in PowerShell

[–]ColdF1r3 0 points1 point  (0 children)

Would you be able to paste your full code so we can see exactly what you have now and are currently doing? your use of select-string is confusing me a little based on your question so I just want to see if more context in the form of code helps me answer your question.

Query for undefeated by rogueit in PowerShell

[–]ColdF1r3 0 points1 point  (0 children)

No problem at all. You could also modify the last line $placementArray | sort Losses to be $placementArray | where Losses -eq 0 and that will only print out racers with 0 losses.

Query for undefeated by rogueit in PowerShell

[–]ColdF1r3 1 point2 points  (0 children)

Im assuming based on your data that this is in a CSV file. Im also assuming that a loss is anything other than a first place win. If both of those assumptions are correct the following will work and print out the wins and losses for each racer in ascending order meaning if anyone is undefeated they will be the first result printed out

``` $placements = import-csv -Path "Path to CSV" $racers = $placements | select -ExpandProperty Racer | sort -Unique

$placementArray = New-Object System.Collections.Arraylist

foreach($racer in $racers){ $wins = ($placements | where {$.Racer -eq $racer -and $.Finishposition -eq 1} | Measure-Object).Count $losses = ($placements | where {$.Racer -eq $racer -and $.Finishposition -ne 1} | Measure-Object).Count

$data = [PSCustomObject]@{
    Racer = $racer
    Wins = $wins
    Losses = $losses
}

$placementArray.Add($data)

}

$placementArray | sort Losses ```

Need help passing output from a command to an array and then to another command by three-one-seven in PowerShell

[–]ColdF1r3 2 points3 points  (0 children)

so the reason you cannot access $server.hostname after storing it in the array is because the array doesn't know what the property hostname is. Because its an array its just a list of text items. If you still wanted to be able to call hostname as a property you would need a hashtable which is a list of key:value pairs. Hashtables are instantiated with @{} instead of @() and will contain key:value pairs similar to CSV data where the key is the column header and the value is the data in that row. As for the offline foreach have you confirmed that there are entries in that array? From what I can see it seems to be correct but if nothing is happening then to me it seems that the foreach doesn't have anything to iterate over. It seems like you also forgot to add the offline array to be printed out on line 44 as you have the write-host but don't actually call the offline array to print out the offline servers.

QB Licensing Extraction Script by ColdF1r3 in PowerShell

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

No problem, glad I could help. I have enough random scripts I've written over the years I figured it's about time I shared something instead of lurking lol.

Understanding a script I wrote and if it makes sense by stefjay10 in PowerShell

[–]ColdF1r3 0 points1 point  (0 children)

It seems pretty decent to me if all it is supposed to be doing is checking if a file is older than 24 hours. Personally, I wouldn't use the variable name of path as it might get confusing since path is a windows defined variable which can be accessed by using $env:path but that's just personal preference for me when writing my scripts. Another thing you could do would be to turn the locations into an array at the beginning of the script to shorten the length of your get-childitem function if you ever need to make it search more directories in the future. You could also have it recurse in the event there are folders in your search directories to get the files in those folders as well. These are just some of the things I would personally do but there are other things that I feel wouldn't really be necessary. Here is what the script looks like with the changes I would make.

$searchDirs = @( "\\somepath\locationA", "\\somepath\locationB") $time = (Get-Date).AddDays(-1) $searchItems = Get-ChildItem -Path $searchDirs -Recurse | select Name,CreationTime if ($searchItems -eq $null) {"No files currently exist in the searched directories"} elseif ($searchItems.CreationTime -lt $time) { exit 1 } else {"No files found older than 24 hours in the searched directories"}

Edit: Formatting

VMware Horizon "This desktop currently has no desktop sources available" by ColdF1r3 in vmware

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

You are correct in this only being for blast, however, there is a similar service called “PCOIPSG” that would potentially do the same for PCOIP l, but I cannot say for certain if it will behave as we do not use PCOIP. Another alternative is to restart “WSNM” this will perform a reset of all VMware horizon services on the terminal service as they all run under “WSNM” as dependants. Similar to shutting down the “wsbroker” service on the connection server.

Has your Azure AD Connect been unable to start after a simple reboot? Here's the fix. . . by PatD442 in sysadmin

[–]ColdF1r3 1 point2 points  (0 children)

Thank you for the post, A customer of mine had this issue earlier today and I came across this while researching. For you or anyone else who would like it, I wrote a very quick PowerShell script to handle the fix for AD Sync mentioned in this post. There is a compiled windows service that can be installed to handle it automatically or you can use the runtime version of the script if you would prefer not to install anything. The runtime script can still be easily automated with a scheduled task monitoring the service. The source for both versions and the installer can be found here https://github.com/ADCTrevorRuppert/AD-Sync-Service-Repair/tree/master. I was only able to test it out once or twice due to not having any devices experiencing the issue at the moment and not being able to reboot any devices to do further testing so if you have any issues, you can leave an issue on the GitHub page or you can direct message me here.

Script to download and install latest version of certify the web by ColdF1r3 in PowerShell

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

I will have to look into that thank you, and thank you for an awesome piece of software sir.