# Powershell Script not working after saving as .ps1

**URL:** <https://forums.powershell.org/t/powershell-script-not-working-after-saving-as-ps1/6257>\
**Category:** PowerShell Help\
**Created:** [April 19, 2016, 9:19am UTC](https://forums.powershell.org/t/powershell-script-not-working-after-saving-as-ps1/6257 "2016-04-19T09:19:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishal-rao-b](https://avatars.discourse-cdn.com/v4/letter/v/2acd7d/32.png) [@vishal-rao-b](https://forums.powershell.org/u/vishal-rao-b)\
**Post date:** [April 19, 2016, 9:19am UTC](https://forums.powershell.org/t/powershell-script-not-working-after-saving-as-ps1/6257/1 "2016-04-19T09:19:58Z")

</div>

Hi All,

I have Powershell code, I have tested it by pasting the code with Powershell  
it ran without error.  
But, when I have saved it as .PS1 file and trying to run it’s not working, I am receiving error

$path = “C:\Users\beeraval\desktop\Powershell\_work\Source.xlsx”  
$Excel = New-Object -ComObject excel.application  
$Excel.visible = $True  
$Workbook = $excel.Workbooks.open($path)  
$Worksheet = $Workbook.WorkSheets.item(“MBR Metrics”)  
$worksheet.activate()  
$path1 = “C:\Users\beeraval\desktop\Powershell\_work\loaa.xlsx”  
$Excel1 = New-Object -ComObject excel.application  
$Excel1.visible = $True  
$Workbook1 = $excel1.Workbooks.open($path1)  
$Worksheet1 = $Workbook1.WorkSheets.item(“Loaa Data”)  
$worksheet1.activate()  
$range = $WorkSheet.Range(“D:D“).EntireColumn.Delete()  
$range = $WorkSheet.Range(“A4:AM206“)  
$range.Copy() | out-null  
$Worksheet1 = $Workbook1.WorkSheets.item(“Loaa Data”)  
$Range1 = $Worksheet1.Range(“A4“)  
$Worksheet1.Paste($range1)  
$workbook1.Save()

Any help is appreciated

---

<div class="post-metadata">

**Author:** ![windos](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/windos/32/966_2.png) [@windos](https://forums.powershell.org/u/windos)\
**Post date:** [April 19, 2016, 10:20am UTC](https://forums.powershell.org/t/powershell-script-not-working-after-saving-as-ps1/6257/2 "2016-04-19T10:20:35Z")

</div>

What is the error you’re receiving?

---

<div class="post-metadata">

**Author:** ![rdtechie](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rdtechie/32/273_2.png) [@rdtechie](https://forums.powershell.org/u/rdtechie)\
**Post date:** [April 19, 2016, 5:29pm UTC](https://forums.powershell.org/t/powershell-script-not-working-after-saving-as-ps1/6257/3 "2016-04-19T17:29:52Z")

</div>

I guess you’re having the extensions in explorer hidden? And that’s why the ps1 file doesn’t run?

---

<div class="post-metadata">

**Author:** ![windos](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/windos/32/966_2.png) [@windos](https://forums.powershell.org/u/windos)\
**Post date:** [April 19, 2016, 6:36pm UTC](https://forums.powershell.org/t/powershell-script-not-working-after-saving-as-ps1/6257/4 "2016-04-19T18:36:50Z")

</div>

It’s possible the execution policy is restricting it from running.

---

<div class="post-metadata">

**Author:** ![rdtechie](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rdtechie/32/273_2.png) [@rdtechie](https://forums.powershell.org/u/rdtechie)\
**Post date:** [April 19, 2016, 9:27pm UTC](https://forums.powershell.org/t/powershell-script-not-working-after-saving-as-ps1/6257/5 "2016-04-19T21:27:17Z")

</div>

Without knowing the actual error message, it’s only guessing from our side…

---

<div class="post-metadata">

**Author:** ![vishal-rao-b](https://avatars.discourse-cdn.com/v4/letter/v/2acd7d/32.png) [@vishal-rao-b](https://forums.powershell.org/u/vishal-rao-b)\
**Post date:** [April 20, 2016, 6:02am UTC](https://forums.powershell.org/t/powershell-script-not-working-after-saving-as-ps1/6257/6 "2016-04-20T06:02:17Z")

</div>

Hi All, Thank you for your response. I should have mentioned my error clearly.

I was able to resolve my error once I have saved my Code using Powershell ISE.

Its running fine now.

-Vishal

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:41pm UTC](https://forums.powershell.org/t/powershell-script-not-working-after-saving-as-ps1/6257/7 "2024-05-16T20:41:32Z")

</div>


