Hirdetés

Keresés

Új hozzászólás Aktív témák

  • AlyrArkhon

    senior tag

    válasz Clemi #39889 üzenetére

    na megvan a fullos is, kicsit hosszu, de beirom stepbystep :)

    1) rendszergazdai powershellben:

    New-Item –Path $profile –Type file -Force
    Set-ExecutionPolicy –ExecutionPolicy RemoteSigned
    notepad $profile

    2) a megnyíló file-ba:

    function Get-UpTime
    {
    [CmdletBinding()]
    param (
    [Parameter(Position = 0, Mandatory = $false, ValueFromPipeline = $true)]
    [Alias(“CN”)]
    [String]$ComputerName = $Env:ComputerName,

    [Parameter(Position = 1, Mandatory = $false)]
    [Alias(“RunAs”)]
    [System.Management.Automation.Credential()]$Credential = [System.Management.Automation.PSCredential]::Empty
    )
    process
    {
    “{0} Uptime: {1:%d} Days {1:%h} Hours {1:%m} Minutes {1:%s} Seconds” -f $ComputerName,
    (New-TimeSpan -Seconds (Get-WmiObject Win32_PerfFormattedData_PerfOS_System -ComputerName $ComputerName -Credential $Credential).SystemUpTime)
    }
    }

    notepad bezár mentéssel.

    a rendszergazdai powershell ablakban file-megnyitással megnyitod (szép hosszu neve lesz ilyen MicrosoftPowershellSE_$profile1.ps stílusban)
    F5-tel vagy file-run futtatod.
    innentől a powershell ablakban müködni fog a Get-UpTime :

    PS C:\> Get-UpTime
    Uptime: 0 days, 2 hours, 24 minutes

    innen szedtem össze, nem magamtól :) a Serge Nikalaichyk-féle első verzió van bemásolva.

Új hozzászólás Aktív témák

Hirdetés