PS script help me

Hi,
i’m a beginner of PS but I have a need. I would like to wirte a PS script that get logon current user windows pc and an Active Directory attribute. Then wite them on a txt file.
It’s possibile?
Thank you!!

Mario,
Ciao & Welcome to the forum. :wave:t3:

If I got you right - Yes, that’s possible.

What kind of help do you need?

Please keep in mind: This forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

We actually expect you to make an own attempt at the first place to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.

Regardless of all that: If I’ve got you right is what you asked fo a very basic and common task. Something like this has been asked and answered a thousand times already. So there is no need to re-invent the wheel again. Use your prefered internet search engine to look for code examples for such a task.

I already wrote this but I don’t know how to merge this code in unique txt file.

Get-aduser “USER” -Properties * | select “ADAttrbiute” | export-csv c:\admingroup.csv

and

Get-WmiObject –ComputerName COMPUTERNAME –Class Win32_ComputerSystem | Select-Object UserName | export-csv c:\user.csv

I searched online but I don’t find what I need.

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org 1 <---- Click :point_up_2:t4: :wink:

( !! Sometimes the preformatted text button hides behind the settings gear symbol. :wink: )

What do you mean?

What did you search for?

1 Like

At the end I find solution with this command:

Get-Content C:\input.txt | Select-String -Pattern “MyString” -CaseSensitive | Out-File -FilePath C:\Output.txt -Append

but I already have problem that i want “MyString” in a precise location in my output.txt, not in append.

It’s possibile?

Please keep in mind: We cannot see your screen and we cannot read your mind. So you will have to exlplain as much detailed as possible what you want.

You may share a (sanitized) sample of your input file, the pattern you want to look for and the expected output.

And please … When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org 1 <---- Click :point_up_2:t4: :wink:

( !! Sometimes the preformatted text button hides behind the settings gear symbol. :wink: )

And does your answer really have to take 1 day everytime? Do you walk away when you posted something here?? :face_with_raised_eyebrow: