Share via

RUN a command line or Power Shell script using logon on windows machine

PerserPolis-1732 1,841 Reputation points
Jan 22, 2024, 2:33 PM

Hi, I wanna to a command line for example C:\ipconfig /flushdns every time if the user want to login on Windows client, but the user do should not see it during login on Client machine. As I know,I can do that with GPO or logon script for every user Any Idea how I can do that? Regards

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,734 questions
Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,509 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,250 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Daisy Zhou 25,296 Reputation points Microsoft Vendor
    Jan 23, 2024, 2:23 AM

    Hello PerserPolis-1732,

    Thank you for posting in Q&A forum.

    I assume you have one domain, then we can follow the steps below:

    1.Create one OU on Domain Controller.
    2.Put the user accounts that need to run this command line or Power Shell script to this OU. 3.Create one GPO and rename this GPO.

    For example:

    I rename this GPO (GPO name is tt1 and its GUID is {5EE96627-35BD-434C-9C6A-4AE328E7D13A}). User's image

    4.Put the this command line or Power Shell script file to this folder below: \domain.com\SYSVOL\domain.com\Policies{5EE96627-35BD-434C-9C6A-4AE328E7D13A}\User\Scripts\Logon 5.Edit this GPO as below.
    User's image

    User's image

    6.If the specific users logon, then this user will apply the logon GPO.

    I hope the information above is helpful.

    If you have any question or concern, please feel free to let us know.

    Best Regards,
    Daisy Zhou



    If the Answer is helpful, please click "Accept Answer" and upvote it.


  2. PerserPolis-1732 1,841 Reputation points
    Jan 30, 2024, 11:08 AM

    ????????????????????

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.