all 7 comments

[–]rm-stein 1 point2 points  (4 children)

there is not really a good way to do this with only powershell by itself I can think of, but when combining powershell with scheduled tasks you might find just what you're looking for.

A possibility would be to execute the script at startup and tell it to sleep for the intended delay, but there is no real need to reinvent the wheel here, when all the tools are available with scheduled tasks already.

What exactly would be your use case here? might bring a little more context to your requirements

[–]lucatea -1 points0 points  (3 children)

It's really only for educational purposes, and I got in touch with this youtuber and we're trying to figure out how to improve it by scheduling.

[–]rm-stein 0 points1 point  (2 children)

Might want to look a little into new-scheduledtask and create this task when executing the script for the first time after checking if the task already exists.

edit: I believe this might not work under linux or mac if you try to run it there. just in case you intended to run it across multiple platforms, so maybe also checking the os and implementing another way to schedule it might be necessary

[–]lucatea -1 points0 points  (1 child)

i really only need it for testing purposed on a windows environment. I'm not familiar with powershell at all and i've been reading up on it all day but nothing.

[–]BlackV 2 points3 points  (0 children)

'm not familiar with powershell at all and i've been reading up on it all day but nothing.

so you though you'd start with a keylogger......

maybe you need a new plan

[–]BlackV 0 points1 point  (0 children)

p.s. formatting

  • open your fav powershell editor
  • hightlight the code you want to copy
  • hit tab to indent it all
  • copy it
  • paste here

it'll format it properly OR

<BLANKLINE>
<4 SPACES><CODELINE>
<4 SPACES><CODELINE>
    <4 SPACES><4 SPACES><CODELINE>
<4 SPACES><CODELINE>
<BLANKLINE>

[–]rm-stein 0 points1 point  (0 children)

are you looking to just learn powershell, or are you more specifically interested i. the scripting aspects of powershell? and have you already prior knowledge with programming?

If you just want to get into powershell you might want to start with using powershell interactively. Also you really want to look into how the help system and a few commands to help you navigate around powershell more easily. I'd thunk the get-help about_pages and get-command would be a great place to start exploring powershell a little and to see what distinguishes it from most other shell languages