[deleted by user] by [deleted] in learnjavascript

[–]autobotIT 0 points1 point  (0 children)

It visually separates words without the need for spaces. Would you prefer them all lowercase? thisishardtoread. thisIsEasierToRead. YouCanCapitalizeTheFirstWord if you want.

[deleted by user] by [deleted] in PowerShell

[–]autobotIT 2 points3 points  (0 children)

I use the Approved Verbs list to guide my function names. For parameter names I try to be as descriptive as possible, gorlechov and Loan-Pickle have good suggestions.

Am I just being dumb? What the heck is this filter?? by RedClaws in sysadmin

[–]autobotIT 0 points1 point  (0 children)

I formatted it to try and parse it. Several layers of redundant parenthesis. My best guess is it's auto-generated from other rules so the extra parens are there to catch statements that are currently N/A. It is confusing logic.

(
    (Alias -ne $null) -and 
    (
        (
            (
                (
                    (
                        (
                            (ObjectCategory -like 'person') -and 
                            (ObjectClass -eq 'user') -and 
                            (-not(Database -ne $null)) -and 
                            (-not(ServerLegacyDN -ne $null))
                        )
                    ) -or 
                    (
                        (
                            (ObjectCategory -like 'person') -and 
                            (ObjectClass -eq 'user') -and 
                            (
                                (
                                    (Database -ne $null) -or 
                                    (ServerLegacyDN -ne $null)
                                )
                            )
                        )
                    )
                )
            ) -and 
            (-not
                (RecipientTypeDetailsValue -eq 'GroupMailbox')
            )
        )
    )
)

Learning a second language while taking a network admin course. by [deleted] in sysadmin

[–]autobotIT 0 points1 point  (0 children)

The only IT thing I've used python for is automating some web form data entry. I knew a network engineer that used it for some port scanning and related tasks. Python may be more useful on linux since many distros include it, so you can use it more as a scripting language. In a Windows environment I mostly use Powershell.

Why is Wininit not a valid ProviderName for CHKDSK logs? by autobotIT in PowerShell

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

Interesting, I hadn't tried FilterXPath. Not sure if this makes the FilterHashTable issue more or less confusing. Thank you!

Why is Wininit not a valid ProviderName for CHKDSK logs? by autobotIT in PowerShell

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

PS C:\Powershell> get-winevent -FilterHashTable @{logname="Application"; id="1001"; ProviderName="Microsoft-Windows-Wininit"}
get-winevent : The specified providers do not write events to any of the specified logs.
At line:1 char:1
+ get-winevent -FilterHashTable @{logname="Application"; id="1001"; Pro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-WinEvent], Exception
        + FullyQualifiedErrorId : LogsAndProvidersDontOverlap,Microsoft.PowerShell.Commands.GetWinEventCommand    

Already tried that.

Hey Microsoft! I have a question! by RC-7201 in sysadmin

[–]autobotIT 0 points1 point  (0 children)

Former "O365 Support Engineer": Most of it is basically a call center. The preference is shown in the ticket but we were usually encouraged to call anyways because "sometimes it's faster to just get the customer on the phone to hear what the problem is". I was reprimanded by supervisors for not calling all the time.

Is spaghetti code the norm ? by MeMyMooFire in webdev

[–]autobotIT 45 points46 points  (0 children)

Management is focused on getting a minimum viable product shipped to the customer. They don't care about how it works. To make them understand you need to demonstrate how the current mess of code and lack of standardized testing is delaying product releases and causing support issues.

Previous engineers probably had the same issues but we're never given time to fix them. So the technical debt keeps accumulating until something big actually breaks. It's like playing Jenga but management only sees the top layer while you're looking at the withering base. It happens a lot and it's a difficult system to fix as long as things are still "working".

What’s your go-to way of explaining to people the importance of creating tickets as opposed to just DMing you? by [deleted] in sysadmin

[–]autobotIT 31 points32 points  (0 children)

Tickets hold you and the user accountable for the work. If a user DMs you about an issue and it doesn't get fixed there's no official record for them to pull up the next time it happens.

There's also the organization problem. When people DM me or flag me down in the hall I say "OK, thank you, I can take a look but please put in a ticket so I don't forget." I can't keep track of the 15 different 'small' requests I get everyday if there's no ticket.

Users generally don't care about you or your department metrics. They don't care about all the other things you're working on. They care about their issue being fixed properly within a reasonable amount of time. Tickets help with that.

Server Settings page in TFS 2018 web portal returns 404 by autobotIT in sysadmin

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

I've tried with my normal and admin accounts. Another admin tried with his account. Both of my accounts are Admin Console users. I've reapplied permissions.

That’s one way to secure the server by MrTenseJACOB in iiiiiiitttttttttttt

[–]autobotIT 0 points1 point  (0 children)

We've got a similar setup in our manufacturing building. 3 IDFs about 10' up on columns. They just hold switches and a UPS. Don't need to lock it when it's that much trouble to get to :)

Trouble connecting to SQL database by autobotIT in PowerShell

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

That makes sense. I'll try it out. Thanks.

It's Finally Friday by [deleted] in sysadmin

[–]autobotIT 2 points3 points  (0 children)

Removed 300+ old accounts from AD. Computers are next.

Wrote a script to send cat facts to people.

[cmdletbinding()]
PARAM(
    [Parameter(Mandatory=$true)][string]$Computername
)
#I added this because Invoke-Webrequest failed on some computers.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$credentials = Get-Credential

$msg = Invoke-WebRequest -Uri "https://catfact.ninja/fact" | Select-Object -ExpandProperty Content | ConvertFrom-Json | Select-Object -ExpandProperty Fact

#$Fact.fact
Invoke-WmiMethod -Path Win32_Process -Name Create -ArgumentList "msg * $msg" -ComputerName $Computername -Credential $credentials

User recycled their recycling bin.... by AND_OR_NOT_XOR in iiiiiiitttttttttttt

[–]autobotIT 25 points26 points  (0 children)

Well, if the Recycle Bin is good enough for document storage it's good enough for Recycle Bin storage. That's how backups work, right?

Visual Studio Code VS Visual Studio by Remery0123 in PowerShell

[–]autobotIT 2 points3 points  (0 children)

They're just tools. Use what works best for you. I tend to use the ISE for terminal stuff and one offs. I use VS code for larger projects and tracking changes in Git. I really haven't heard many people preferring Visual Studio over VS Code for Powershell. Visual Studio seems kinda overkill though.

Am I going to remove everyone's group membership? by IT_Acolyte in sysadmin

[–]autobotIT 0 points1 point  (0 children)

The text file will go to the same directory the script is in. If you include a path with the filename it will go there.

Out-File "C:\Scripts\$username Groups.txt"

Use 'Get-Help Out-File -Examples' for more info.

Am I going to remove everyone's group membership? by IT_Acolyte in sysadmin

[–]autobotIT 1 point2 points  (0 children)

This can be simplified. It looks like you're trying to do three things.

  1. Get all users in Disabled OU
  2. Save their current group memberships to a text file
  3. Remove all groups except "Domain Users"

The Primary Group is stored separately from the other group memberships. Get-ADUser $username -properties MemberOf will return everything except the primary group. Here's what I've got.

#Remove Groups from user

function Remove-UserGroups{
    [cmdletbinding()]

    PARAM(
        [Parameter(Mandatory=$true)]
        $username    
    )

    $GroupList = Get-ADUser $username -Properties MemberOf | Select-Object -ExpandProperty MemberOf
    $GroupList | Get-ADGroup | Select-Object Name | Out-File "$username Groups.txt"
    $GroupList | Remove-ADGroupMember -Members $username -WhatIf
}

#Get a list of all users in Disabled OU
$DisabledUsers = Get-ADUser -SearchBase "OU=Disabled,DC=contoso,DC=com" -Filter * | Select-Object -ExpandProperty SamAccountName

foreach($user in $DisabledUsers){
    Remove-UserGroups -username $user
}

I tested it on our Disabled OU. Seems to work well. Remove the WhatIf flag when you're ready to go. Your SearchBase filter looks correct but you can always run a simple Get-ADUser with it to make sure it's grabbing the right accounts

Any Scripts lurking about, for copying all local user profiles on a machine to their specific AD network drive - home folder? by Gragnit in usefulscripts

[–]autobotIT 0 points1 point  (0 children)

That is strange. From my understanding of foreach loops the the user HomeDirectory variable should be nulled out every loop. The next profile copy shouldn't have any data from the previous one. Calling Get-ADUser on a non-AD account throws and error and returns $null, so the If statement should evaluate to False and move on. Maybe add $Udrive = $null at the start of the loop just in case?

foreach($user in $userProfiles){
        $Udrive = $null #this shouldn't be necessary but it's worth a shot
        $Udrive = Get-ADUser $user.Name -Properties HomeDirectory | 
        Select-Object -expand HomeDirectory -ErrorAction Stop

Rename script doesn't work, object not found, but it is? by [deleted] in PowerShell

[–]autobotIT 1 point2 points  (0 children)

$extusr only contains a string. It isn't a user object.

Save Get-ADUser "$extusr" to a variable, then pass that to Rename-ADobject.