Jump to content

Running powershell script under windows 8.1 help


heula
Go to solution Solved by TheCaptain,

Recommended Posts

Installed Windows 8.1  and Running into a problem with my scheduled task for hiding and unhiding folders.

 

In windows 7 I ran this scrip without any problem as a scheduled task.

 

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe 

 

with parameter -command C:\hidefolders-Series Alex.ps1

 

Now I have seen that powershell is located in windows 8 here, %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe

 

When I add that loaction still nothing happens.

 

When I run the powershell script without the task scheduler it runs fine.

 

How can I run this script in windows 8.1 working?

 

 

Same thing happening to scheduled tasks that run batch files. Not working in windows 8. Working in Windows 7. What is changed and need to be changed for me?

Edited by heula
Link to comment
Share on other sites

In your Win8 installation, did you set the account that will run the scheduled task? Not sure how Win8 handles this, but in other versions, there is usually a place to add the user credentials.

Link to comment
Share on other sites

In your Win8 installation, did you set the account that will run the scheduled task? Not sure how Win8 handles this, but in other versions, there is usually a place to add the user credentials.

It did always run under the system account but I have tried as administrator and under my local account. Nothing works.

This is the code it returns under my local account.  0xFFFD0000

 

My tasks with batch file are working now but the powershell scripsts not.

Link to comment
Share on other sites

This is the used code that worked in windows 7.

 $fs = New-Object -ComObject scripting.filesystemobject
Get-ChildItem “J:\Series Alex\” -force | Where-Object {$_.psiscontainer} | ForEach-Object {
    if($fs.getfolder($_.fullname).size -lt 50mb) {$_.attributes = "directory,hidden"}
    else{$_.attributes = "directory"}
}

Perhaps someone can make something like this that can run in a batch and does the same thing. Hide folders under 50 mb and unhide folders if the size get's over 50mb?

Link to comment
Share on other sites

Hmm. Whenever I've had issues similar to this (not with Powershell thoough), the problem is either permissions (account and/or folder access permissions) or the starting path needs to be specified.

 

It seems you've eliminated account permissions. How about the permissions for the directory "J:\Series Alex\" ? Does it and all sub-directories have the proper NT permissions set so the system account (or whatever user you are using to run the scheduled task) have full access to that directory?

 

I'm not familiar with Powershell. But in some batch files, I had to specify the full working path of whatever command I am trying to run and/or set the "start in" property of the scheduled task to point to the batch file's location.
 

Link to comment
Share on other sites

  • Solution
TheCaptain

1. Open group policy editor

2. Navigate to: Computer Configuration/Administrative Templates/Windows Components/Windows Powershell

3. Double click "Turn on Script Execution"

4. Click the Enabled option

5. Change Execution policy to: "Allow local scripts and remote signed scripts"

6. Click "OK"

 

It should work fine after that, windows 8.1 has scripting disabled by default

Edited by TheCaptain
  • Like 1
Link to comment
Share on other sites

1. Open group policy editor

2. Navigate to: Computer Configuration/Administrative Templates/Windows Components/Windows Powershell

3. Double click "Turn on Script Execution"

4. Click the Enabled option

5. Change Execution policy to: "Allow local scripts and remote signed scripts"

6. Click "OK"

 

It should work fine after that, windows 8.1 has scripting disabled by default

You are my hero of the day! Many hours wasted but you solved it for me.

Thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...