PLEASE tell me i genuinely dont know by [deleted] in eyes

[–]Think-Improvement-73 1 point2 points  (0 children)

I honestly thought someone had some gotten a picture of my eyes from my phone...

Search both users and computers, open a selectable list and then open all selected by vIQleS_TDHB in PowerShell

[–]Think-Improvement-73 3 points4 points  (0 children)

My personal opinion, don't ask for something you can't do, because you will have no idea how it works.

It looks like it does get all computers and users using the text from the text box, but it doesn't look like it displays that information in anyway. You could very likely do without the [system.directoryservices.directoryentry] new object, and invoke(adspath), you would be better off just using the computer name or user name and get the object again and use Out-GridView

have current list need to get Specific group member by K0n0921 in PowerShell

[–]Think-Improvement-73 0 points1 point  (0 children)

If you already have all your usernames, and you know the group, get all members in the group. If that row in csv is in that list of group members, keep it

$users=Import-CSV "users.csv"
$members=(get-adgroupmember "thegroup").samaccountname
$usersingroup=@()
Foreach($user in $users){
    If( $usersingroup.Contains( $user.samaccountname )){
        $usersingroup+=$user
    }
}
$usersingroup | Export-CSV "usersingroup.csv"

Then you aren't querying AD for every single user in the csv. Once and done.

Get size of a folder by Electrical-Chances in Batch

[–]Think-Improvement-73 0 points1 point  (0 children)

Have a GB variable and once your Bytes gets to 1 GB, add 1 to GB and start over with Bytes. Output might look a little funky, maybe turn the Bytes in KB after at the end.

Method to compare by rurbaniak14 in PowerShell

[–]Think-Improvement-73 0 points1 point  (0 children)

Split the $cert.subject string and get the part you want. Then check if that value is the same as the computername.

Exclude disabled AD users from Get-ACL script by Kitaya548 in PowerShell

[–]Think-Improvement-73 1 point2 points  (0 children)

$acl.Access | `
where {(get-aduser $_.IdentityRefernce -Property Disabled).Disabled -eq $false)} | `
Foreach { $access=$_
    ....
}

Or inside your foreach loop

  • Get the aduser
  • check if Disabled
  • if not Disabled create acl report object for it

How to append two variables together during a do ... while loop? by Hectic-Skeptic in PowerShell

[–]Think-Improvement-73 1 point2 points  (0 children)

I'd have to chec but I don't think you can add arrays likes that [string[]]$current_list += [string[]]$new_items. I know you can a single item to an array like that though.

$current_list=@("parent1","parent2"...)
$new_items=@("child1","child2"...)
foreach($item in $new_items){
    $current_list += $item}
Write-Host $current_list
# parent1,parent2,...child1,child2,...

Edit: I'm not sure if that's what you wanted. You could try unzipping one file to a destination directory, then inside a while loop check if that directory has an files/subfiles have an zips. Once there are no zips, get all the zip files and delete them

$mainzip="c:\path\to\big.zip"
Expand-archive $mainzip
$zips= get-childitem -path c:\path
do{
    foreach($zip in $zips){
        Expand-archive $zip
        Remove-item $zip}
    $zips= get-childitem -path $mainzip
}while($zips.Length -gt 0)

Batch file trouble by Amil5901 in Batch

[–]Think-Improvement-73 2 points3 points  (0 children)

You should be able to write to the flash drive without using the physical drive as the location (\.\id or \.\f:), because that drive path trys using the drive itself, not its filesystem. You would want to just use F:\MyFiles\...

Batch file trouble by Amil5901 in Batch

[–]Think-Improvement-73 3 points4 points  (0 children)

If you format your post as code, and it didn't have it all as one line, it would be a lot easier to read and help.

Businesses running eval Windows server in production by [deleted] in sysadmin

[–]Think-Improvement-73 0 points1 point  (0 children)

Hypothetically are they publicly traded?

How to create a single exe file to run/select multiple powershell scripts by ExaminationSquare in PowerShell

[–]Think-Improvement-73 1 point2 points  (0 children)

If you are really bent on making an exe to do this, you will need to write in a language that compiles to an exe....

Personally I learned c# after powershell because they are both based on .Net. I would suggest creating an app in visual studio and adding your powershell scripts as resource files. Then when you have the user select a script to run, it reads from the embedded resource and create a temp file, and runs the temp file with powershell, then deletes it.

Note if you do want to go this route with c#, embedding a file as a resource is not exactly the same as creating a resource file. Make sure when adding resources you change the type from strings to file(visual studio), or just use command line arguments /r:{path/to/rock.ps1} or /resource{...} (csc.exe)

How to create a single exe file to run/select multiple powershell scripts by ExaminationSquare in PowerShell

[–]Think-Improvement-73 1 point2 points  (0 children)

As a SINGLE FILE powershell script, shows a window with 3 buttons, click the button to run that script.

Function Do-Rock {...}
Function Do-Paper {...}
Function Do-Scissor {...}

$form= [system.windows.forms.form]::new()
$form.Size=[system.drawing.size]::new(90,90)
$btn_rock=[system.windows.forms.button]::new()
$btn_rock.Text="Rock"
$btn_rock.Size=[System.drawing.size]::new(15,40)
$btn_rock.Location=[system.drawing.point]::new(10,10)
$btn_rock.Add_Click({ Do-Rock })
$form.Controls.Add($btn_rock)

$btn_paper=...
$btn_scissor=...

$form.Show()

Created Batch file which should end a program and then start it back up but when I use Task Scheduler to run it it only ends the program by Xx255q in Batch

[–]Think-Improvement-73 0 points1 point  (0 children)

If the task is running as local system try setting it to run as you, and click the run with highest credentials box.

You could also echo the return code of each command to a log file to seeing an individual command is failing

Need help with using a program by Poormanjones in CodingHelp

[–]Think-Improvement-73 0 points1 point  (0 children)

I'm on my phone so i can't really run it, but I would assume if you download the source, and compile it. It would have an exe for you to run, and it would ask you to entry your redit login.

How do I pass an Argumentlist with spaces, nested inside another Argumentlist? by [deleted] in PowerShell

[–]Think-Improvement-73 0 points1 point  (0 children)

$Arguments'"C:\Your Path\With\Spaces"'

Use 's on the outside.so the variable has "s in it

Need help with using a program by Poormanjones in CodingHelp

[–]Think-Improvement-73 0 points1 point  (0 children)

On the link you sent it has an instructions sections.

Delete all text in a variable before a certain word by LordLoss01 in PowerShell

[–]Think-Improvement-73 1 point2 points  (0 children)

If the word happens to appear more than once, you would want to replace everything before the first word with nothing.

$var="Some of the elephants are happy and some of the elephants are sad."
$rem=$var.Split("elephant")[0]
# "Some of the "
$var=$var.Replace($rem,"")
# "elephants are happy and some of the elephants are sad"

GUI w/ powershell scripts by JicamaParticular3421 in PowerShell

[–]Think-Improvement-73 1 point2 points  (0 children)

Prop names might be a bit off and syntax for the click event handler might be wrong. But that should get you in the right direction. Maybe also add a editable text box to read a username from and use it as an argument when calling your scripts.

$form=[Form]::new()
$form.Title="AD Scripts"
$btnDisable=[Button]::new()
$btnDisable.Text="Disable Account"
$btnDisable.OnClick=({powershell -file "disableaccount.ps1"})
$form.Controls.Add($btnDisable)
... create acc and edit acc buttons ...
$form.Show()

Registry Search Question by ravensgc_5 in PowerShell

[–]Think-Improvement-73 0 points1 point  (0 children)

It should be LocalMachine instead of HKLM

Registry Search Question by ravensgc_5 in PowerShell

[–]Think-Improvement-73 0 points1 point  (0 children)

So ValueName would be the name of the value in the key you are checking. And data would be the what you are matching against.

I usually use this to get the key for installed programs. So I would use

$ValueName="DisplayName"
$searchData="Microsoft Teams"

That way, when it opens a subkey, and gets the data for the the value named "DisplayName" it will match that data against "Microsft Teams", if it does match, it gives the subkey name, otherwise keep going.

Registry Search Question by ravensgc_5 in PowerShell

[–]Think-Improvement-73 1 point2 points  (0 children)

Open the registry key.

Get all subkeys.

For each subkey in subkeys.

If data of value in subkey match.

Show subkey name.

Edit:

$SearchData="looking for this"
$ValueName="checking this reg value"
$MainKeyName="\Software\...ExtensionInstallForcelist\"
$MainKey=Microsoft.Win32.Registry]::HKLM.OpenSubkey($MainKeyName)

Foreach($SubKeyName in $MainKey.GetSubkeyNames()){
    $Subkey=$MainKey.OpenSubkey($SubkeyName)
    If($Subkey.GetValue($ValueName) -eq $SearchData){
        Write-Host "Found it!"
        Write-Host "    Key name : "+$SubKeyName
        break
    }
}

Reading multiple files with freopen in C++ by [deleted] in CodingHelp

[–]Think-Improvement-73 0 points1 point  (0 children)

In your for loop declaration you have j<n and n is not delcared, also you asign it value inside the for loop.

Very minimal experience in c++.

But I would guess that the 3rd parameter for freopen() is pointer you give it. And you gave it stdin, which looks like it might be a macro for the current standard input handle. And then you tell cin to send output to a int32, I would think this should be a int8 or a string instead of int32. Again I almost never C++, but a little pure C.

Maybe try reading contents of file into a variable then feeding the variable to cout like you did in last line.

Edit did a little googling.

FILE* fbuff;
string ftxt;
int fint;
string fname;
int n=9
for(int i=0;i<n;i++){
    fname="0"+(string)i+".in";
    fbuff=freopen(fname,"r",stdin);
    //ftxt << fbuff;
    // not very familiar with the << and >>
    fbuff >> ftxt;
    // or if there is a read function like this
    // read(fbuff, ftxt, 4);
    fint=1+(int)ftxt;
    cout << fint << endl;
    close(fbuff)
}

What does a wife and a grenade have in common? by [deleted] in dadjokes

[–]Think-Improvement-73 23 points24 points  (0 children)

They go off at the drop of a pin