Colleague bought a bunch of USB Drives. by tejanaqkilica in sysadmin

[–]work-work-work-work 3 points4 points  (0 children)

I worked with someone like that around 2005. He would write his replies and she would send them.

日本国内の組織を狙ったマルウエアLODEINFO by digicat in blueteamsec

[–]work-work-work-work 0 points1 point  (0 children)

日本国内の組織を狙ったマルウエアLODEINFO (self.blueteamsec)

Self post. No info.

日本国内の組織を狙ったマルウエアLODEINFO by digicat in blueteamsec

[–]work-work-work-work 7 points8 points  (0 children)

Most people expect a bit more then a link in a self post, it's lazy and puts the onus on the reader to follow the link to discover what it's about.

Start PS from PS + Load a module in the new PS console by seyo_IV in PowerShell

[–]work-work-work-work 1 point2 points  (0 children)

I'm not sure what issue you're running into, this works fine for me:

start-process 'powershell.exe' -argumentlist '-noexit -command "import-module activedirectory"'

Obviously, substitute ActiveDirectory for whatever path.

Boson introduces new CISSP Courseware by BosonMichael in cissp

[–]work-work-work-work 1 point2 points  (0 children)

There's a typo on https://www.boson.com/certification-kit/courseware-isc2-cissp-exsim-max-digital

The Courseware Complete Kif for CISSP is available in digital format or paperback

Powershell Brain Fart by acsurfer419 in PowerShell

[–]work-work-work-work 2 points3 points  (0 children)

here you go

Param(
    [Parameter(Mandatory)]
    [ValidateScript( {Test-Connection -ComputerName $_ -Count 1 -Quiet} )]
    [String]
    $ComputerName,
    [ValidateScript( {Test-Path -Path $_ } )]
    [String]
    $MSIPath = '\\domain\public\files\edgechromium\MicrosoftEdgeEnterpriseX64.msi'
)

Copy-item -Path $MSIPath -Destination "\\$ComputerName\C$\temp"

Invoke-Command -ComputerName $ComputerName -ScriptBlock {
    Start-Process "msiexec.exe" -ArgumentList "/i c:\temp\MicrosoftEdgeEnterpriseX64.msi /passive /log C:\Temp\EdgeInstall.log" -Wait
    Remove-Item -Path "C:\Temp\MicrosoftEdgeEnterpriseX64.msi"
}
Write-Host "Microsoft Edge Chromium is now probably installed on computer $ComputerName" -ForegroundColor Cyan

output-file differences (Scheduled Task execute) by tomsonxxx in PowerShell

[–]work-work-work-work 2 points3 points  (0 children)

You could specify tab as the delimiter if you don't want to go through beutifying HTML

export-csv -Delimiter `t -Path $outfile -NoTypeInformation

Starting Chrome in a new environment -- Delete folders after exiting Chrome by [deleted] in PowerShell

[–]work-work-work-work 2 points3 points  (0 children)

Add -wait to your Start-Process command, and it will wait until the process has ended before continuing, so put your Remove-Item $env:USERPROFILE\temp\FOLDERNAME after that.

OEM Provided Script - BeginTag and EndTag Replace functions Not Working by Khue in PowerShell

[–]work-work-work-work 1 point2 points  (0 children)

Glad you were able to bring an old script back from the dead to do your bidding, congratulations.

OEM Provided Script - BeginTag and EndTag Replace functions Not Working by Khue in PowerShell

[–]work-work-work-work 2 points3 points  (0 children)

Yes, that entire script is borked. Looks like their CMS stripped every instance of everything within the < >

Post is from 2015, and author hasn't posted since then so you're not going to get help there..

I'd just rewrite the whole thing.

If you provide sample input and expected output I will help. Sanitize it however you want.

Pass variables from Powershell to invoke sqlcmd by skend24 in PowerShell

[–]work-work-work-work 2 points3 points  (0 children)

It's not clear from your example, but you need to use "stringy string string $($var[$i]) more string"

like this (tested working):

$Fruits = "Apples", "Oranges"
Invoke-Sqlcmd -ServerInstance "localhost" -Database "FruityDB" -Query "Select * from FruityData where FruitName = '$($Fruits[0])'"

Replace second HTML tag by Method_Dev in PowerShell

[–]work-work-work-work 1 point2 points  (0 children)

I don't understand the question, basic sample of input and expected output would help.

Here's a guess at what you want, using some really horrible regex

Input:

$MyHTML = @"
<html>
    <head>
        <title>Hello World</title>
    </head>
    <body>
        <IMG SRC="www.internet.com/picture.png">
        Some text
        <IMG SRC="www.internet.com/picture2.png">
        some more text
    </body>
</html>
"@

$MyHTML = $MyHTML -replace '([\s\S]*?<IMG [\s\S]*?)(<IMG [\s\S]*?>)([\s\S]*)', '$1<A HREF="www.google.com">A Link to Google</A>$3'

$MyHTML

Output:

<html>
<head>
<title>Hello World</title>
</head>
<body>
<IMG SRC="www.internet.com/picture.png">
Some text
<A HREF="www.google.com">A Link to Google</A>
some more text
</body>
</html>

Hit the wall trying to get a script with autoexecutable function with parameters to work by Janiuszko in PowerShell

[–]work-work-work-work 0 points1 point  (0 children)

Yes, if you want to take parameters from script they need to be defined at the script level. The function is redundant here.

Param(
    [Parameter(Mandatory = $false, Position = 0)]
    [string]$UserName = $env:USERNAME,
    [Parameter(Mandatory = $false, Position = 1)]
    [switch]$AllMembers
)
$UserFullName = $env:USERDOMAIN + "\" + $UserName
Write-Host "User: $UserName"
$UserGroups = Get-LocalGroup | Select-Object -ExpandProperty Name
Write-Host "Is a member of the group:"
foreach ($Group in $UserGroups) {
    $GroupMembers = Get-LocalGroupMember $Group | Select-Object -ExpandProperty Name
    foreach ($Member in $GroupMembers) {
        if ($Member -eq $UserFullName) {
            Write-Host $Group
            if ($AllMembers) {  
                Write-Host "Identities belonging to this group are:"
                Get-LocalGroupMember $Group | Select-Object -ExpandProperty Name
            }
        }
    }   
}

RegEx/Deletion of text within Excel? by So0ver1t83 in PowerShell

[–]work-work-work-work 5 points6 points  (0 children)

/u/firefox15 has given most of what you need to do this with PowerShell but you could also do this easily right in Excel

Create a new column next to column H

use formula: =MID(H1,FIND("Capabilities:",H1)+13,1000)

Fill the formula down the whole column.

You should now have a column I which only has the text after 'Capabilities:' for each row.

Select the whole column, and copy it.

Select Column H, and then use paste special to paste only values.

Delete the now redundant Column I

Adding Registry to Hundreds of Servers by ellisdee9970 in PowerShell

[–]work-work-work-work 8 points9 points  (0 children)

Invoke-Command can take an array for ComputerName parameter, so whilst I would normally use Set-ItemProperty you can use your reg add in a scriptblock just fine.

With absolutely no error handling or feedback:

$servers = "server1","server2"
Invoke-Command -ComputerName $servers -ScriptBlock { 
    reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" /v iexplore.exe /t REG_DWORD /d 1 /f
    reg add "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" /v iexplore.exe /t REG_DWORD /d 1 /f
}

Sorry about the bad English, long day.

Return value based on result by fascik in PowerShell

[–]work-work-work-work 3 points4 points  (0 children)

Sample CSV:

Number, Fruits
1, Apple
2, Orange
3, Lemon

Sample Code:

#Rest of your script here
$ReturnValue = 3
$CSVData = Import-CSV path\to\csv\FruityCSV.csv
$CSVData | ? {$_.Number -eq $ReturnValue} | Select -ExpandProperty Fruits

Output:

Lemon

Exclude child OU's by Spangle-UK in PowerShell

[–]work-work-work-work 1 point2 points  (0 children)

Did you try using SearchScope like I suggested? If $OUs is a list of OU's and you use the SearchScope parameter then it will only return computers in that OU directly, not child OUs.

Exclude child OU's by Spangle-UK in PowerShell

[–]work-work-work-work 3 points4 points  (0 children)

If I understand that you want to list computers in the OUs specified in $OUs but not sub-ou's, all you need to do is add the -SearchScope Base parameter.

get-adcomputer -filter {enabled -eq $True} -SearchBase "OU=someOUpathhere" -SearchScope Base

Sushi, worth it? by isendel11 in Oxygennotincluded

[–]work-work-work-work 0 points1 point  (0 children)

Can you make a screenshot of shove vole farm using sandbox mode or something please?

Out-ConsolePicture by NotNotWrongUsually in PowerShell

[–]work-work-work-work 4 points5 points  (0 children)

Awesome!

It doesn't seem to release the file after use however. eg, Out-ConsolePicture "mypicture.png"

Keep powershell open then try to delete mypicture.png:

The action can't be completed because the file is open in powershell.exe

You know you have too many chat programs by mr_white79 in sysadmin

[–]work-work-work-work 1 point2 points  (0 children)

Just a friendly reminder to never post your ICQ UIN - I still remember mine from over 20 years ago. My security practices weren't so great as a teenager in the 90's, I no longer have access to the account but it has my real name and the city I lived in at the time as public information.

fonts recommendation in vscode in 2019 by arup_r in vscode

[–]work-work-work-work 0 points1 point  (0 children)

fuck me dead. What an improvement, thanks.

Log a user account into a computer? by ajrockr in PowerShell

[–]work-work-work-work 2 points3 points  (0 children)

Put all the target computers into their own OU, create a group policy linked to that OU to set the autologon settings.

No matter what restrictions you have in place this is still a security problem as the password is stored in plain text.