Closed itsRealGray closed 1 year ago
so, this is an easy fix
You can either fix this yourself - or use this pull request
Download the scrpt, or copy the contents into a .ps1
file onto your machine and modify the script with the below code
Completely replace the first if-statement with this:
#If the file does not exist, create it.
if (!(Test-Path -Path $PROFILE -PathType Leaf)) {
try {
# Detect Version of Powershell & Create Profile directories if they do not exist.
if ($PSVersionTable.PSEdition -eq "Core" ) {
if (!(Test-Path -Path ($env:userprofile + "\Documents\Powershell"))) {
New-Item -Path ($env:userprofile + "\Documents\Powershell") -ItemType "directory"
}
}
elseif ($PSVersionTable.PSEdition -eq "Desktop") {
if (!(Test-Path -Path ($env:userprofile + "\Documents\WindowsPowerShell"))) {
New-Item -Path ($env:userprofile + "\Documents\WindowsPowerShell") -ItemType "directory"
}
}
Invoke-RestMethod https://github.com/ChrisTitusTech/powershell-profile/raw/main/Microsoft.PowerShell_profile.ps1 -o $PROFILE
Write-Host "The profile @ [$PROFILE] has been created."
}
catch {
throw $_.Exception.Message
}
}
Then simply call the script ./setup.ps1
or whatever you called it.
@ChrisTitusTech the -ne "True"
is not required at all and breaks on most peoples setups (including mine)
So, instead you should remove those args and then do a boolean negation with the !
operator instead.
You should also lowercase the If
to if
. Then, your logic will work flawlessly on all machines :)
Thanks
Merged #17
As instructed Elevated PowerShell pasting the One Line Install line this error is popping up every time. -
Cannot bind parameter 'NewerThan'. Cannot convert value "True" to type "System.DateTime". Error: "The string was not recognized as a valid DateTime. There is an unknown word starting at index 0." At line:19 char:10