I want to create a directory with a .ps1 file and then copy the text of the file from the beginning and put it inside the created directory with a .ps1 extension. Something like this
$dirpath="c:\mydirectory"
If (! (Test-path $dirpath)){
New-Item -Itemtype directory -path $dirpath
Code to copy the text from $dirpath to the end of file rename to anyname.ps1 and put it in the created directory
}
More code
} # end of file
Or once completed the execution then the code here
$filepath="c:\mydirectory\myfile"
IF (! (Test-path $filepath)) {
Copy line by line from $dirpath until #end of file and create myfile and put it in the directory created
}
Thanks