-
Posts
452 -
Joined
-
Last visited
Content Type
Forums
News
20th
EduGeek EDIT Conference
Blogs
Everything posted by tri_94
-
Depending which version of Framework/Powershell your running if you use the following two powershell commands (Get-WmiObject Win32_MonitorDetails -ComputerName $env:COMPUTERNAME | Select-Object -Property Model).Model -join ", " (Get-WmiObject Win32_MonitorDetails -ComputerName $env:COMPUTERNAME| Select-Object -Property SerialNumber).SerialNumber -join ", " You will be able to get Make, Model and Serial Number's Thanks
-
Windows 10 1607,1809 and New version of Edge (Required Windows updates)
tri_94 replied to tri_94's topic in Windows 10
Thanks for the info. I've found out that it needs a cumulative update. -
If its going to be easier to just return file name instead of data then they will work fine. Thanks
-
Thanks for that I've tried that one and it doesn't seem to work for me.
-
Which method did you use? I'd only be using for cross reference purposes
-
Hi there I'm after a way to get Monitor serials to add to a current powershell script. I would use Get-WmiObject Win32_MonitorDetails as that worked great for my test pc however the pc's I need to use it on don't have that i get invalid class and for WMIMonitorID I get not supported. Thanks
-
Them 4 work perfect thanks for that.
-
I've now got the spacing working on the emails. I removed -bodyasHTML. There is still a couple of issues, for Model, Serial and OU I get @{}, So like model returns @{Model=OptiPlex 3060} is there an easy way to remove the @{} ? Also for Windows Updates doesn't seem to work for, if I run the command direct it does. Many thanks Add-Type -AssemblyName System.Windows.Forms [system.Windows.Forms.Application]::EnableVisualStyles() $FormName = New-Object system.Windows.Forms.Form $FormName.ClientSize = '400,400' $FormName.text = "Form" $FormName.TopMost = $false $Label1 = New-Object system.Windows.Forms.Label $Label1.text = "Please Enter Computer Name" $Label1.AutoSize = $true $Label1.width = 25 $Label1.height = 10 $Label1.location = New-Object System.Drawing.Point(10,20) $Label1.Font = 'Microsoft Sans Serif,10' $TextBox1 = New-Object system.Windows.Forms.TextBox $TextBox1.multiline = $false $TextBox1.width = 374 $TextBox1.height = 20 $TextBox1.location = New-Object System.Drawing.Point(10,40) $TextBox1.Font = 'Microsoft Sans Serif,10' $Button1 = New-Object system.Windows.Forms.Button $Button1.text = "Click to Find IP \ Mac Address of Computer" $Button1.width = 374 $Button1.height = 30 $Button1.location = New-Object System.Drawing.Point(10,65) $Button1.Font = 'Microsoft Sans Serif,10' $Label2 = New-Object system.Windows.Forms.Label $Label2.text = "Email Address" $Label2.AutoSize = $true $Label2.width = 25 $Label2.height = 10 $Label2.location = New-Object System.Drawing.Point(11,320) $Label2.Font = 'Microsoft Sans Serif,10' $Button2 = New-Object system.Windows.Forms.Button $Button2.text = "Send As Email" $Button2.width = 150 $Button2.height = 25 $Button2.location = New-Object System.Drawing.Point(235,339) $Button2.Font = 'Microsoft Sans Serif,10' $TextBox2 = New-Object system.Windows.Forms.TextBox $TextBox2.multiline = $false $TextBox2.width = 220 $TextBox2.height = 20 $TextBox2.location = New-Object System.Drawing.Point(10,340) $TextBox2.Font = 'Microsoft Sans Serif,10' $OutputBox1 = New-Object system.Windows.Forms.TextBox $OutputBox1.width = 374 $OutputBox1.height = 200 $OutputBox1.multiline = $true $OutputBox1.location = New-Object System.Drawing.Point(10,100) $FormName.controls.AddRange(@($Label1,$TextBox1,$Button1,$Label2,$Button2,$Outputbox1,$Textbox2)) #$Global:data = "" $smtpServer = "" $Button1.Add_Click({Get-MAC }) $Button2.Add_Click({Send }) function Get-MAC { $Computer = $Textbox1.Text if($Computer -eq $null) { $Computer = $env:COMPUTERNAME } $hostIp = [system.Net.Dns]::GetHostByName($Computer).AddressList[0].IpAddressToString if($Credential) { $Credential = Get-Credential $Credential $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -Credential $Credential -ComputerName $Computer } else { $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -ComputerName $Computer } $obj = New-Object PSObject $obj | Add-Member NoteProperty "ComputerName"($Computer) $obj | Add-Member NoteProperty "IPAddress" ($hostIp) $obj | Add-Member NoteProperty "MacAddress"($wmi | where { $_.IpAddress -eq $hostIp }).MACAddress $obj | Add-Member NoteProperty "LastReboot"((Get-WmiObject win32_operatingsystem -ComputerName $Computer | select @{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}).LastBootUpTime) $obj | Add-Member NoteProperty "WindowsVersion"(Get-WmiObject -class Win32_OperatingSystem -ComputerName $Computer ).Caption $obj | Add-Member NoteProperty "WindowsBuild"(get-wmiobject -class win32_OperatingSystem -ComputerName $Computer ).BuildNumber $obj | Add-Member NoteProperty "OU" (Get-ADComputer -Identity $Computer | Select-Object DistinguishedName) $obj | Add-Member NoteProperty "Model" (Get-WmiObject Win32_ComputerSystem -ComputerName $Computer | Select-Object -Property Model) $obj | Add-Member NoteProperty "SerialNumber" (Get-WmiObject Win32_BIOS -ComputerName $Computer| Select-Object -Property SerialNumber) $obj | Add-Member NoteProperty "WindowsUpdates"(get-hotfix -ComputerName $Computer | Select-Object HotfixID) $OutputBox1.Text = "Computer Name = " + $obj.ComputerName + " Computer Name:" + $obj.ComputerName + " IP Address: " + $obj.IPAddress + " MAC Address: " + $obj.MacAddress + " Computer Model: " + $obj.Model + " Computer Serial: " + $obj.SerialNumber + " Last Rebooted: " + $obj.LastReboot + " Windows Version: " + $obj.WindowsVersion + " Windows Build: " + $obj.WindowsBuild + " Computer OU: " + $obj.OU +" Windows Updates = " + $obj.WindowsUpdates } function Send { $Computer = $Textbox1.Text if($Computer -eq $null) { $Computer = $env:COMPUTERNAME } $hostIp = [system.Net.Dns]::GetHostByName($Computer).AddressList[0].IpAddressToString if($Credential) { $Credential = Get-Credential $Credential $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -Credential $Credential -ComputerName $Computer } else { $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -ComputerName $Computer } $obj = New-Object PSObject $obj | Add-Member NoteProperty "ComputerName"($Computer) $obj | Add-Member NoteProperty "IPAddress" ($hostIp) $obj | Add-Member NoteProperty "MacAddress"($wmi | where { $_.IpAddress -eq $hostIp }).MACAddress $obj | Add-Member NoteProperty "LastReboot"((Get-WmiObject win32_operatingsystem -ComputerName $Computer | select @{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}).LastBootUpTime) $obj | Add-Member NoteProperty "WindowsVersion"(Get-WmiObject -class Win32_OperatingSystem -ComputerName $Computer ).Caption $obj | Add-Member NoteProperty "WindowsBuild"(get-wmiobject -Class win32_OperatingSystem -ComputerName $Computer ).BuildNumber $obj | Add-Member NoteProperty "OU" (Get-ADComputer -Identity $Computer | Select-Object DistinguishedName) $obj | Add-Member NoteProperty "Model" (Get-WmiObject Win32_ComputerSystem -ComputerName $Computer | Select-Object -Property Model) $obj | Add-Member NoteProperty "SerialNumber" (Get-WmiObject Win32_BIOS -ComputerName $Computer| Select-Object -Property SerialNumber) $obj | Add-Member NoteProperty "WindowsUpdates"(get-hotfix -ComputerName $Computer | Select-Object HotfixID) $EmailBody =" Computer Name: " + $obj.ComputerName + "`n IP Address: " + $obj.IPAddress + "`n MAC Address: " + $obj.MacAddress + "`n Computer Model: " + $obj.Model + "`n Computer Serial: " + $obj.SerialNumber + " `n Last Rebooted: " + $obj.LastReboot + "`n Windows Version: " + $obj.WindowsVersion + "`n Windows Build: " + $obj.WindowsBuild + "`n Computer OU: " + $obj.OU + "`n`n Windows Updates = " + $obj.WindowsUpdates $EmailAddress = $Textbox2.Text Send-Mailmessage -smtpServer $smtpServer -from [email protected] -to $EmailAddress -subject "IP / MAC Details for $Computer" -body $EmailBody -priority High Write-Host "Button Clicked" } [void]$FormName.ShowDialog()
-
Sorry think you were replying at the same time. This bit you've take out was left over from before, is was a different way of finding last reboot time by querying event log. I had already removed it from Get-Mac but not Send.
-
Thanks for it does show the details some much better now. I've tested the email side and slight change but it working now. When it emails is displays like Computer Name = mypc IP Address =000.000.000.000 MAC Address = AA:AA:AA:AA:AA:AA Last Reboot1 = 06/26/2020 11:17:36 Windows Version = Microsoft Windows 10 Enterprise 2016 LTSB Windows Build = 14393 Is there any way to include line spaces i've tried `n but maybe i did it wrong. Thanks again for your help.
-
It would be handy to have the information and thinking about at the bottom of the html is a " Generated: 03-July-2020 08:03, Duration: 0 min 34 sec
-
Yep spot on i missed that part. Thanks that seems to work. Is there an easy way to create a for each for this. I've tried this method but not sure how to pass the filename as $_.Fullname as i get a permission denied "PermissionDenied: (D:\test\01_03_2020\20_16_01.71:String)" as it will need to be D:\test\01_03_2020\20_16_01.71\Status.html As you can see from the code below i'm hoping to export the details would it be possible to add the filename to the export. Thanks $Path = "D:\test\01_03_2020" $Server = "Server1" $Text = "0.5%" $output = "d:\test\Results.txt" Get-ChildItem $Path -Recurse -Filter "*" -Depth 10 | ForEach-Object { $results = Get-HTMLTables -File $_.FullName -Depth 10 -FirstRowHeader $true $results.0 | Where-Object {$_.Server -match $Server -and $_.'CPU Usage' -eq $Text}} | Write-host "$_.Fullname" Out-File $output
-
Brill thanks for the reply's, that looks a good way forward. I've had a quick look and get this error. But it still did return Site : Memory Usage : Server : Server1 CPU Usage : Uptime : Group : Disk Usage : Status : Offline You cannot call a method on a null-valued expression. At line:57 char:1 + $tables = $page.ParsedHtml.body.getElementsByTagName('Table') + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: ( [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Thanks
-
Hi I'm working on a basic GUI that has the ability to get ip, mac and last reboot time of a pc and also gives the ability to send the information as a email. The code below works for everything except the last reboot doesn't seem to work, not sure why as if i run it basically the same line direct it will. Other slight issue is the way in which is displays the information can any help make it more user friendly. Many Thanks Add-Type -AssemblyName System.Windows.Forms [system.Windows.Forms.Application]::EnableVisualStyles() $FormName = New-Object system.Windows.Forms.Form $FormName.ClientSize = '400,400' $FormName.text = "Form" $FormName.TopMost = $false $Label1 = New-Object system.Windows.Forms.Label $Label1.text = "Please Enter Computer Name" $Label1.AutoSize = $true $Label1.width = 25 $Label1.height = 10 $Label1.location = New-Object System.Drawing.Point(10,20) $Label1.Font = 'Microsoft Sans Serif,10' $TextBox1 = New-Object system.Windows.Forms.TextBox $TextBox1.multiline = $false $TextBox1.width = 374 $TextBox1.height = 20 $TextBox1.location = New-Object System.Drawing.Point(10,40) $TextBox1.Font = 'Microsoft Sans Serif,10' $Button1 = New-Object system.Windows.Forms.Button $Button1.text = "Click to Find IP \ Mac Address of Computer" $Button1.width = 374 $Button1.height = 30 $Button1.location = New-Object System.Drawing.Point(10,65) $Button1.Font = 'Microsoft Sans Serif,10' $Label2 = New-Object system.Windows.Forms.Label $Label2.text = "Email Address" $Label2.AutoSize = $true $Label2.width = 25 $Label2.height = 10 $Label2.location = New-Object System.Drawing.Point(11,320) $Label2.Font = 'Microsoft Sans Serif,10' $Button2 = New-Object system.Windows.Forms.Button $Button2.text = "Send As Email" $Button2.width = 150 $Button2.height = 25 $Button2.location = New-Object System.Drawing.Point(235,339) $Button2.Font = 'Microsoft Sans Serif,10' $TextBox2 = New-Object system.Windows.Forms.TextBox $TextBox2.multiline = $false $TextBox2.width = 220 $TextBox2.height = 20 $TextBox2.location = New-Object System.Drawing.Point(10,340) $TextBox2.Font = 'Microsoft Sans Serif,10' $OutputBox1 = New-Object system.Windows.Forms.TextBox $OutputBox1.width = 374 $OutputBox1.height = 200 $OutputBox1.multiline = $true $OutputBox1.location = New-Object System.Drawing.Point(10,100) $FormName.controls.AddRange(@($Label1,$TextBox1,$Button1,$Label2,$Button2,$Outputbox1,$Textbox2)) #$Global:data = "" $smtpServer = "" $Button1.Add_Click({Get-MAC }) $Button2.Add_Click({Send }) function Get-MAC { $Computer = $Textbox1.Text if($Computer -eq $null) { $Computer = $env:COMPUTERNAME } $hostIp = [system.Net.Dns]::GetHostByName($Computer).AddressList[0].IpAddressToString if($Credential) { $Credential = Get-Credential $Credential $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -Credential $Credential -ComputerName $Computer } else { $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -ComputerName $Computer } $obj = New-Object PSObject $obj | Add-Member NoteProperty "Computer Name"($Computer) $obj | Add-Member NoteProperty "IP Address" ($hostIp) $obj | Add-Member NoteProperty "Mac Address"($wmi | where { $_.IpAddress -eq $hostIp }).MACAddress $obj | Add-Member NoteProperty "Last Reboot"(Get-WmiObject win32_operatingsystem | select $Computer, @{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}) $Outputbox1.Text = $obj } function Send { $Computer = $Textbox1.Text if($Computer -eq $null) { $Computer = $env:COMPUTERNAME } $hostIp = [system.Net.Dns]::GetHostByName($Computer).AddressList[0].IpAddressToString if($Credential) { $Credential = Get-Credential $Credential $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -Credential $Credential -ComputerName $Computer } else { $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -ComputerName $Computer } $obj = New-Object PSObject $obj | Add-Member NoteProperty "Computer Name"($Computer) $obj | Add-Member NoteProperty "IP Address" ($hostIp) $obj | Add-Member NoteProperty "Mac Address"($wmi | where { $_.IpAddress -eq $hostIp }).MACAddress $obj | Add-Member NoteProperty "Last Reboot"(get-eventlog system | where-object {$_.eventid -eq 6005} | select Timegenerated, EntryType, Source, Message -first 10) $obj | Add-Member NoteProperty "Last Reboot"(Get-WmiObject win32_operatingsystem | select $Computer, @{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}) $Outputbox1.Text = $obj Write-Output $obj $EmailAddress = $Textbox2.Text Send-Mailmessage - smtpServer $smtpServer -from [email protected] -to $EmailAddress -subject "IP / MAC Details for $Computer" -body """$obj""" -bodyasHTML -priority High Write-Host "Button Clicked" } [void]$FormName.ShowDialog()
-
Hi there I have a system in place that checks servers and generates html with a table. If a problem occurs i'd like to be able to check all the files to check when this happened. So i need to check on two criteria's first would be Server name and second would be like cpu usage or offline status. I'm trying to check 100's of html files. I've tried things like $file = "D:\test\Status.html" $content = Get-Content $file If($content -match 'Server1') {Write-Host "Match"} Else {Write-Host "No Match"} which works fine for server name but due to the format of the html table I can't seem to find a way to check for server name and same server offline. Any help would be great Many Thanks The Html file's are this code format. Server Status Server CPU Usage Memory Usage Disk Usage Uptime Site Group Status Server1 Microsoft Windows Server 2019 Datacenter 1.25% 20% C: 30% E: 43% 1 days 8h 4m Site1 Online Generated: 03-July-2020 08:03, Duration: 0 min 34 sec
-
Does anyone use a web front end ? Thanks
-
Thank you both for your info. Its just having have used the likes of Project Fog. The way in which I can have a new pc and pxe and then it adds the pc to database is a really useful thing. I think I've found that MDT can do this https://deployvista.com/2010/09/17/insert-computers-automatically-into-the-mdt-database/
-
Hi there Having never used MDT and SQL database together just wondering in how people use it? Also is it possible for a new pc to prompt for a computer name and ou etc and have that data along with the serial number wrote back to the database? I know the Linux Project Fog has an inventory setting which you can do this type of thing. Many thanks
-
Thank you for that. I’m sure that will do it now
-
nope there official documentation tell you to run REG QUERY HKLM\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /s /f SOPHOS > C:\Sophos_Uninstall_Strings.txt and then tell you to copy and paste to this example Uninstall string MsiExec.exe /X{01423865-551B-4C59-B44A-CC604BC21AF3}
-
Hi there i'm looking to create an uninstaller sophos and been told by sophos that each machine will have different reg keys. So they tell you to query the reg and copy and paste the keys into a bat file to make a uninstaller each time. I'd like to use powershell do query and uninstall Using the code below i can see the information i need $data = Get-ItemProperty 'HKLM:\Software\microsoft\Windows\CurrentVersion\Uninstall\*' | Where-Object { ($_.Publisher -ilike "Sophos Limited") -and $_.PSChildname -notlike "S*" } | Select-Object Displayname , PSChildname Info returned DisplayName PSChildName ----------- ----------- Sophos AMSI Protection {0EA5323F-DE1B-480C-911E-7827E5EAXXXX} Sophos Endpoint Firewall {2831282D-8519-4910-B339-2302840AXXXX} Sophos Network Threat Protection {4B1F9009-CD85-43C0-BCBD-D491908DXXXX} Sophos Endpoint Self Help {4EFCDD15-24A2-4D89-84A4-857D1BF6XXXX} Sophos Exploit Prevention {866151B2-E14E-40E0-B6D9-64B1D428XXXX} Sophos Endpoint Agent {8D7BB12C-6854-46DF-A67D-F82D778DXXXX} Sophos File Scanner {CD39E739-F480-4AC4-B0C9-68CA731DXXXX} So now i was going to use (as the uninstall command is basically MsiExec.exe /X {CD39E739-F480-4AC4-B0C9-68CA731DXXXX} foreach ($entry in $data) { MsiExec.exe /X $data.pschildname } But I think my problem is the info is being seen as a single block of text rather the individual lines Many Thanks
-
Hi there, Which version of Windows 10 are you using? As you can get FOD ISO from the licensing portal which will include the calculator. If I recall I made this PowerShell script to reinstall. (version is 1809), seemed to recall that it required one or both of the Microsoft.UI.Xaml, Microsoft.VCLibs #Remove the Calc Package Remove-AppxPackage -Package "Microsoft.WindowsCalculator_8wekyb3d8bbwe" #Install Microsoft.UI.Xaml Add-AppxPackage "D:\Apps\Microsoft.UI.Xaml.2.0_2.1810.18004.0_x64__8wekyb3d8bbwe.Appx" #Install Microsoft.VCLibs.140.00_14.0.27323.0 Add-AppxPackage "D:\Apps\Microsoft.VCLibs.140.00_14.0.27323.0_x64__8wekyb3d8bbwe.Appx" #Install Calc Package Add-AppxPackage "Microsoft.WindowsCalculator_8wekyb3d8bbwe.appxbundle" Thanks
-
The reasons why is at current it opens the grid view doesn't auto scroll, You have to type in the powershell window so have to have both showing. When your busy doing something else its two easy to miss messages. It not about it looking nice, just really want to be able to use it in a single form.
-
Hi there I've got the following code with works as i require, however i would perfer not to use Out-GridView for displaying. I would prefer a really basic Text window for chats and under a box to enter text. Like the code below creates. I just can't seem to work out how to put the two together as when i have tried the GUI doesn't appear only the gridview. Im sure if you know how this is a very simple fix. Please help Many Thanks <# This form was created using POSHGUI.com a free online gui designer for PowerShell .NAME Untitled #> Add-Type -AssemblyName System.Windows.Forms [system.Windows.Forms.Application]::EnableVisualStyles() $Form = New-Object system.Windows.Forms.Form $Form.ClientSize = '859,676' $Form.text = "Form" $Form.TopMost = $false $ListView1 = New-Object system.Windows.Forms.ListView $ListView1.text = "listView" $ListView1.width = 787 $ListView1.height = 461 $ListView1.location = New-Object System.Drawing.Point(31,19) $TextBox1 = New-Object system.Windows.Forms.TextBox $TextBox1.multiline = $false $TextBox1.width = 787 $TextBox1.height = 20 $TextBox1.location = New-Object System.Drawing.Point(32,516) $TextBox1.Font = 'Microsoft Sans Serif,10' $Form.controls.AddRange(@($ListView1,$TextBox1)) #Write your logic code here [void]$Form.ShowDialog() ------------------------------------------------- Chatroom Code below $ServerShare = "\\Share" function Enter-Chat { param ( [Parameter(Mandatory)] [string] $ChatChannelName, [string] $Name = $env:USERNAME, [switch] $ShowOldPosts, $HomeShare = $ServerShare ) if ($ShowOldPosts) { $Option = '' } else { $Option = '-Tail 0' } $Path = Join-Path -Path $HomeShare -ChildPath "$ChatChannelName.txt" $exists = Test-Path -Path $Path if ($exists -eq $false) { $null = New-Item -Path $Path -Force -ItemType File } $process = Start-Process -FilePath powershell -ArgumentList "-noprofile -windowstyle hidden -command Get-COntent -Path '$Path' $Option -Wait | Out-GridView -Title 'Chat: [$ChatChannelName]'" -PassThru Write-Host "To exit, enter: quit" "[$Name entered the chat]" | Add-Content -Path $Path do { Write-Host "[$ChatChannelName]: " -ForegroundColor Green -NoNewline $inputText = Read-Host $isStopCommand = 'quit','exit','stop','leave' -contains $inputText if ($isStopCommand -eq $false) { "[$Name] $inputText" | Add-Content -Path $Path } } until ($isStopCommand -eq $true) "[$Name left the chat]" | Add-Content -Path $Path $process | Stop-Process } Enter-Chat -ChatChannelName RemoteSupport -Name User -ShowOldPosts
