• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 497
  • Last Modified:

Create shared folder on desktop with powershell

When I run the lines below one at a time in powershell everything works.  I thought I could just paste the text in notepad and save it with a .ps1 extension then run it in powershell to automate the steps but that didn't work.  I have no powershell experience so pardon my ignorance.  How do I turn these individual lines into the powershell equivalent of a batch file?

# Check if the folder exists and if not create a folder named scans on users desktop
IF (!(TEST-PATH c:\users\"$env:username"\Desktop\Scans)) {NEW-ITEM c:\users\"$env:username"\Desktop\Scans -type Directory }

# assign wmiclass win32_share to variable $Shares

# Share the folder
1 Solution
HogRingAuthor Commented:
I figured it out, I pasted the text in notepad and saved it as a ps1 file then in group policy logon script added the file on the powerscript tab.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now