Comments (20)
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 ', '')}
}
from powershell-profile.
@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```
from powershell-profile.
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
from powershell-profile.
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.
from powershell-profile.
@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.
from powershell-profile.
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
from powershell-profile.
@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
from powershell-profile.
Also, is there a way to make it work on powershell 7?
from powershell-profile.
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/
from powershell-profile.
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.
from powershell-profile.
@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 ', '')}
from powershell-profile.
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'.
from powershell-profile.
@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.
from powershell-profile.
I think i do, but i might be wrong?
PS C:\Windows\System32> $profile
C:\Users\iopdev\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
from powershell-profile.
@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.
from powershell-profile.
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.
from powershell-profile.
@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.
from powershell-profile.
all good now ty
from powershell-profile.
all good now ty
Glad to help!
from powershell-profile.
Merged fix from @TheyCallMeZ
commit dd1a411
from powershell-profile.
Related Issues (20)
- Web request status endless loop
- Endlessly Promping during Installation HOT 2
- installation issue..... HOT 1
- Installation broke HOT 6
- InvalidOperation: The script failed due to call depth overflow.
- Test-Connection errors HOT 2
- Changes made to the profile are discarded after a restart
- A parameter cannot be found that matches parameter name 'TimeoutSeconds'. HOT 1
- Suggestion about Oh-My-Posh config change HOT 1
- edit-profile does not point to $profile HOT 3
- Delete command from curl
- A few issues when running the install...
- Test-connection -TimeSeconds parameter not recongnized (NamedParameterNotFound) HOT 4
- Fonts ZIP file missing in installation folder? HOT 3
- Bitdefender blocking install HOT 1
- Suggestion add fastfetch on startup
- Lost personal configuration when update HOT 4
- Nothing happens after install HOT 4
- Fail on Test-Connection HOT 3
- Loading personal and system profiles takes around 10 seconds HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from powershell-profile.