4sysops
  • Posts
    • Blog
    • Wiki
    • PowerShell Wiki
    • News
  • Forums
    • IT Administration Forum
    • PowerShell Forum
    • Community Forum
  • Community
    • Register
    • Site-Wide Activity
    • PowerShell Group
    • PowerShell Wiki
    • Members
    • Contribute to the 4sysops community
    • Member point system and prize
    • Member Ranks
    • Member Leaderboard – This Month
    • Member Leaderboard – This Year
    • Member Leaderboard – All-time
    • Author Leaderboard – Last 30 Days
    • Author Leaderboard – This Year
  • Sitemap
    • Cloud Computing
    • Deployment
    • Security
    • Monitoring
    • Networking
    • PowerShell
    • Sitemap
  • About
    • About
    • Authors
    • Write for 4sysops
    • Sponsors
    • Contact
  • Login

Clayton

Home Members Clayton

4sysops - The online community for SysAdmins and DevOps

show less show more
Profile picture of Clayton

@wildhawkz

Member Points balance: 149
Author Points balance: 0
Rank: 2
  • Activity
  • Profile
  • Clayton's Points
  • Friends 0
  • Groups 1
  • Forums
  • Wiki
  • Personal
  • Mentions
  • Favorites
  • Friends
  • Groups
  • Profile picture of Clayton

    Clayton commented on Group logo of PowerShellHow to build a PowerShell inventory script for Windows Servers 2 years, 9 months ago

    The final block of code should be more like the following. 

    Users might need to enable PSRemotting and have admin credentials to connect to the server/workstation.

    [CmdletBinding()]
    param(
    	[Parameter()]
    	[ValidateNotNullOrEmpty()]
    	[string[]]$Servers
    )
    
    foreach ($server in $servers) {
        $output = [ordered]@{
            'ServerName'         = $server
            'OperatingSystem'    = (Get-CimInstance -ComputerName $server -ClassName Win32_OperatingSystem).Caption
            'FreeDiskSpace (GB)' = [Math]::Round(((Get-CimInstance -ComputerName $server -ClassName Win32_LogicalDisk | Measure-Object -Property FreeSpace -Sum).Sum / 1GB),1)
            'Memory (GB)'        = (Get-CimInstance -ComputerName $server -ClassName Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum).Sum /1GB
        }
        [pscustomobject]$output
    }
  • Profile picture of Clayton

    Clayton commented on Group logo of PowerShellManaging Services the PowerShell way – Part 1: Get Service status 3 years, 8 months ago

    You can use the following command in a batch file. The only need for this style of calling Powershell would be needed when using Powershell commands in conjunction with other batch commands…

    Just update the NAME_OF_FILE, the script will get the local path using the %~dp0 in-front of the filename.ps1.

    PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dp0NAME_OF_FILE.ps1""' -Verb RunAs}"
  • Profile picture of Clayton

    Clayton liked comment of sri on Managing Services the PowerShell way – Part 1: Get Service status. (So far, sri has 1 likes for this comment.) 3 years, 8 months ago

  • Profile picture of Clayton

    Clayton commented on Group logo of PowerShellCreate a GUI for your PowerShell script with WPF 3 years, 8 months ago

    By creating GUIs with PowerShell in this manner, is it reliant on the .NET framework version a user is using?

  • Profile picture of Clayton

    Clayton commented on Group logo of PowerShellPowerShell script to query file versions on remote computers 3 years, 11 months ago

    You could add the items in the txt file as you did. Then you could put do a foreach loop for the files and run the QueryFileVersionsRemotely.ps1 file.

    $files = Get-Content C:pathtofiles.txt
    Foreach($line in $files){
    .QueryFileVersionsRemotely.ps1 -ComputerName (Get-Content D:TempComputerlist.txt) -Path $line -OutputFile C:TempFileVersionInfo.csv
    }

    The $line Variable should be the full path of the file. The trick is now to find a way to rename the output file to a different name for each file type.

    Or if the files are in the same directory you could pipe the command as well.

    ls | .QueryFileVersionsRemotely.ps1 -ComputerName (Get-Content D:TempComputerlist.txt) -Path "." -OutputFile C:TempFileVersionInfo.csv
  • Profile picture of Clayton

    Clayton liked comment of Puma on PowerShell script to query file versions on remote computers. (So far, Puma has 2 likes for this comment.) 3 years, 11 months ago

  • Profile picture of Clayton

    Clayton commented on Group logo of PowerShellRemotely query user profile information with PowerShell 4 years, 2 months ago

    Since you are saving the file as “WindowsProfiles.ps1” that will be what you need to call in the console. in the example above, the author saved the file as “Get-WindowsProfiles.ps1”. That is why you are getting the error you stated.

  • Profile picture of Clayton

    Clayton liked comment of D on