I have written a bit of script to speed up on directory making and copying a file into one of them. it works fine in ISE (and PowerGUI)
How ever i can not get in to run by right clicking the PS1 file. I’ve even created a shortcut pointing to both PS and the PS1 file and changed the Reg setting to allow one click running of PS1 files.
All that happens in a PS box opens then closes straight away.
Here is a copy of what I’ve written
========================================
#Written by Jay O’Donnell to help Automate PCexport Extrarates 05/2016
#Variables
$currentuser = [environment]::UserName
$CustomerID = Read-Host -prompt “CustomerID”
$ProductID = Read-Host -Prompt “Product Number”
$Year = Read-Host -Prompt “Year”
$Month = Read-Host -Prompt “Month”
#Mapps in the G drive if it has fallen off
(
New-PSDrive -name “G” -PSProvider FileSystem -Root “\alliesfile01\Gdrive”
)
#Create the directories for both input and out put files
(
New-Item -itemType Directory -Path “C:\Users$currentuser\Desktop$CustomerID$ProductID”
)
(
New-Item -itemType Directory -Path “C:\Users$currentuser\Desktop\export$year$Month$CustomerID$ProductID”
)
#Copies and renames the Modle file in to a formated Control file with in new input directory
(
copy-Item “G:\paf\apps\APIexport\current\exe\EXTRACT.MDL” -Destination C:\Users$currentuser\Desktop$CustomerID$ProductID
)
(
rename-item “C:\Users$currentuser\Desktop$CustomerID$ProductID\EXTRACT.MDL” -newname Change$CustomerID$ProductID.CTL
)
(
Read-Host “Press ENTER”
)