Closed PMJeffery closed 1 year ago
The correct install command is
irm "https://github.com/ChrisTitusTech/powershell-profile/raw/main/setup.ps1" | iex
this goes to the raw script on github rather than the Blob page with all the html
Good call @TheyCallMeZ
I tried that and now got this:
PS C:\Users\susername\Downloads> irm "https://github.com/ChrisTitusTech/powershell-profile/raw/main/setup.ps1" | iex
Exception:
Line |
8 | throw $_.Exception.Message
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
| Could not find a part of the path 'C:\Users\username\Documents\PowerShell\Microsoft.PowerShell_profile.ps1'.
I do not have that folder in my Documents folder. I added it, but created the folder and reran the command and it seems to work.
@PMJeffery That's interesting. The script successfully detected that you did not have an existing profile, but what's more interesting to me is that you didn't have the folder that would contain the profile. Either way you should be good to go from here.
Still getting the error message when powershell opens:
Set-Alias : Não é possível associar o argumento ao parâmetro 'Value' porque ele é nulo.
No C:\Users\iopdev\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:142 caractere:28
+ Set-Alias -Name vim -Value $EDITOR
+ ~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-Alias], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetAliasCommand
@SHJordan You can fix this in one of two ways, if you want to have the alias of "vim" in your powershell you can edit the large if block to look something like this. Or you can Comment out the line setting the alias for vim.
$EDITOR='nvim'
} elseif (Test-CommandExists pvim) {
$EDITOR='pvim'
} elseif (Test-CommandExists vim) {
$EDITOR='vim'
} elseif (Test-CommandExists vi) {
$EDITOR='vi'
} elseif (Test-CommandExists code) {
$EDITOR='code'
} elseif (Test-CommandExists notepad) {
$EDITOR='notepad'
} elseif (Test-CommandExists notepad++) {
$EDITOR='notepad++'
} elseif (Test-CommandExists sublime_text) {
$EDITOR='sublime_text'
}
Set-Alias -Name vim -Value $EDITOR```
@SHJordan You can fix this in one of two ways, if you want to have the alias of "vim" in your powershell you can edit the large if block to look something like this. Or you can Comment out the line setting the alias for vim.
$EDITOR='nvim' } elseif (Test-CommandExists pvim) { $EDITOR='pvim' } elseif (Test-CommandExists vim) { $EDITOR='vim' } elseif (Test-CommandExists vi) { $EDITOR='vi' } elseif (Test-CommandExists code) { $EDITOR='code' } elseif (Test-CommandExists notepad) { $EDITOR='notepad' } elseif (Test-CommandExists notepad++) { $EDITOR='notepad++' } elseif (Test-CommandExists sublime_text) { $EDITOR='sublime_text' } Set-Alias -Name vim -Value $EDITOR```
that worked for me. thank you
Also, is there a way to make it work on powershell 7?
@SHJordan
You can run the setup on Powershell 7 but a number of the functions in Chris's script do not work such as uptime.
If you just want the themed shell without all the extras Chris has baked in, I suggest installing oh my posh by following the installation guide on their website.
https://ohmyposh.dev/
@SHJordan
You can run the setup on Powershell 7 but a number of the functions in Chris's script do not work such as uptime. If you just want the themed shell without all the extras Chris has baked in, I suggest installing oh my posh by following the installation guide on their website. https://ohmyposh.dev/
i see... thats too bad... the looks are ok to get but i was more into the scripts.
@SHJordan Which parts of the script are not working for you in powershell 7?
You can replace the uptime function with either of these.
function uptime {
# Needed to split the offset because of wmi reporting it in minutes instead of hours and minutes
$bootUpTime = Get-WmiObject win32_operatingsystem | Select-Object lastbootuptime
$plusMinus = $bootUpTime.lastbootuptime.SubString(21,1)
$plusMinusMinutes = $bootUpTime.lastbootuptime.SubString(22, 3)
$hourOffset = [int]$plusMinusMinutes/60
$minuteOffset = 00
if ($hourOffset -contains '.') { $minuteOffset = [int](60*[decimal]('.' + $hourOffset.ToString().Split('.')[1]))}
if ($hourOffset -lt 10 ) { $hourOffset = "0" + $hourOffset + $minuteOffset } else { $hourOffset = $hourOffset + $minuteOffset }
$leftSplit = $bootUpTime.lastbootuptime.Split($plusMinus)[0]
$upSince = [datetime]::ParseExact(($leftSplit + $plusMinus + $hourOffset), 'yyyyMMddHHmmss.ffffffzzz', $null)
Get-WmiObject win32_operatingsystem | Select-Object @{LABEL='Machine Name'; EXPRESSION={$_.csname}}, @{LABEL='Last Boot Up Time'; EXPRESSION={$upsince}}
}
function uptime {
net statistics workstation | Select-String "since" | foreach-object {$_.ToString().Replace('Statistics since ', '')}
When i run the script on pwsh 7.2.7 i get:
PS C:\Windows\System32> irm "https://github.com/ChrisTitusTech/powershell-profile/raw/main/setup.ps1" | iex
Exception:
Line |
8 | throw $_.Exception.Message
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
| Could not find a part of the path 'C:\Users\iopdev\Documents\PowerShell\Microsoft.PowerShell_profile.ps1'.
@SHJordan do you have the Powershell folder in your Documents folder? I saw this on someone else's issue as well.
Alternatively you can open your profile and paste the whole or parts of the profile script in to gain those features.
I think i do, but i might be wrong?
PS C:\Windows\System32> $profile
C:\Users\iopdev\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
@SHJordan You need to actually check, $PROFILE is a system variable that reports where it should be, it doesn't actually check for existence.
I had to create a dummy account to get a clean slate and see if the folder is there by default and it is not.
Create that Powershell Folder in your Documents folder, run the setup after that and you should be good to go.
Indeed. I had to create the folder and fix the editor alias, other than that all seems good to go now. ty for your patience.
@SHJordan Which parts of the script are not working for you in powershell 7?
You can replace the uptime function with either of these.
function uptime { # Needed to split the offset because of wmi reporting it in minutes instead of hours and minutes $bootUpTime = Get-WmiObject win32_operatingsystem | Select-Object lastbootuptime $plusMinus = $bootUpTime.lastbootuptime.SubString(21,1) $plusMinusMinutes = $bootUpTime.lastbootuptime.SubString(22, 3) $hourOffset = [int]$plusMinusMinutes/60 $minuteOffset = 00 if ($hourOffset -contains '.') { $minuteOffset = [int](60*[decimal]('.' + $hourOffset.ToString().Split('.')[1]))} if ($hourOffset -lt 10 ) { $hourOffset = "0" + $hourOffset + $minuteOffset } else { $hourOffset = $hourOffset + $minuteOffset } $leftSplit = $bootUpTime.lastbootuptime.Split($plusMinus)[0] $upSince = [datetime]::ParseExact(($leftSplit + $plusMinus + $hourOffset), 'yyyyMMddHHmmss.ffffffzzz', $null) Get-WmiObject win32_operatingsystem | Select-Object @{LABEL='Machine Name'; EXPRESSION={$_.csname}}, @{LABEL='Last Boot Up Time'; EXPRESSION={$upsince}} }
function uptime { net statistics workstation | Select-String "since" | foreach-object {$_.ToString().Replace('Statistics since ', '')}
This actually isnt displaying the time, and the second version is actually broken.
@SHJordan
Corrected Both
function uptime {
# Needed to split the offset because of wmi reporting it in minutes instead of hours and minutes
$bootUpTime = Get-WmiObject win32_operatingsystem | Select-Object lastbootuptime
$plusMinus = $bootUpTime.lastbootuptime.SubString(21,1)
$plusMinusMinutes = $bootUpTime.lastbootuptime.SubString(22, 3)
$hourOffset = [int]$plusMinusMinutes/60
$minuteOffset = 00
if ($hourOffset -contains '.') { $minuteOffset = [int](60*[decimal]('.' + $hourOffset.ToString().Split('.')[1]))}
if ([int]$hourOffset -lt 10 ) { $hourOffset = "0" + $hourOffset + $minuteOffset.ToString().PadLeft(2,'0') } else { $hourOffset = $hourOffset + $minuteOffset.ToString().PadLeft(2,'0') }
$leftSplit = $bootUpTime.lastbootuptime.Split($plusMinus)[0]
$upSince = [datetime]::ParseExact(($leftSplit + $plusMinus + $hourOffset), 'yyyyMMddHHmmss.ffffffzzz', $null)
Get-WmiObject win32_operatingsystem | Select-Object @{LABEL='Machine Name'; EXPRESSION={$_.csname}}, @{LABEL='Last Boot Up Time'; EXPRESSION={$upsince}}
}
function uptime {
net statistics workstation | Select-String "since" | foreach-object {$_.ToString().Replace('Statistics since ', '')}
}
all good now ty
all good now ty
Glad to help!
Merged fix from @TheyCallMeZ commit dd1a411979d0a5f7290ac0d4a19c1b01078f3442
Running Windows 10, PowerShell 7.2.7 with or without "Run as Administrator" and in a writable directory (c:\Users\Username\Downloads)
When running the install command "irm "https://github.com/ChrisTitusTech/powershell-profile/blob/main/setup.ps1" | iex"
Output: "The '<' operator is reserved for future use."
Exits without doing anything
Tried in older Powershell 5.1.x and gets tons of errors, but similar to the above error message.