View htmlHereString.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$user = 'Sam' | |
$html = @" | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> | |
<meta http-equiv="Content-Language" content="en-gb"> | |
<title>WELCOME</title> | |
<style type="text/css"> | |
table.MsoNormalTable { |
View gist:fbfb75dbae73264bc7c91682ad733a5d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get data | |
$svcs = Get-Service | Select -First 5 | |
$svcsHtml = @" | |
<html> | |
<head></head> | |
<body> | |
<p>Some text.</p> | |
<p>Some more text.</p> | |
<br/> |
View gist:ee87defd8dfd80965627a8cd5bdb105c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Drive excerpt from https://social.technet.microsoft.com/Forums/en-US/2d57e836-3ceb-4ce9-9b0c-a09bb8ade259/slow-logon-caused-by-drive-mapping-group-policy?forum=winserverGP | |
#replaced q1: for simplicity in XML parse | |
[xml]$gpo = @" | |
<?xml version="1.0" encoding="utf-16"?> | |
<DriveMapSettings clsid="{8FDDCC1A-0C3C-43cd-A6B4-71A6DF20DA8C}"> | |
<Drive clsid="{935D1B74-9CB8-4e3c-9914-7DD559B7A417}" name="A:" status="A:" image="3" changed="2016-09-07 09:56:23" uid="{7D73B874-DDFD-4696-A8BE-5019E87F0C32}" bypassErrors="1" disabled="0"> | |
<GPOSettingOrder>1</GPOSettingOrder> | |
<Properties action="D" thisDrive="NOCHANGE" allDrives="NOCHANGE" userName="" path="" label="" persistent="0" useLetter="0" letter="A"></Properties> | |
<Filters> |
View Parse-XML.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$log = @" | |
<Event xmlns='http://schemas.microsoft.com/win/2004/08/events/event'> | |
<System> | |
<Provider Name='Service Control Manager' Guid='{555908d1-a6d7-4695-8e1e-26931d2012f4}' EventSourceName='Service Control Manager'/> | |
<EventID Qualifiers='16384'>7036</EventID> | |
<Version>0</Version> | |
<Level>4</Level> | |
<Task>0</Task> | |
<Opcode>0</Opcode> | |
<Keywords>0x8080000000000000</Keywords> |
View htmlreport.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$LogFolder = "c:\util\logs" | |
$LogFile = "pendingrebootreportservers.csv" | |
$LogFile1 = "pendingrebootreportcomputers.csv" | |
$command = “.\Get-PendingReboot.ps1" | |
remove-item -path $LogFolder\$LogFile -Force |
View Report-Example.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$results = foreach ( $DHCPServer in $DHCPServerList ){ | |
if (Test-Connection -ComputerName $DHCPServer -Count 2 -Quiet) { | |
try { | |
## Export the DHCP Server Configuration to a Folder ## | |
$dhcpExportPath = "\\SharedPath\01_XML_Backup\$DHCPServer\$DHCPServer-$(get-date -f yyyy-MM-dd).xml" | |
#Take a look at splatting | |
$dhcpExport = @{ | |
ComputerName = $DHCPServer | |
File = $dhcpExportPath |
View New-DiskSpaceReportWithLinq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -AssemblyName System.Xml.Linq | |
$disks = Get-WMIObject -Class Win32_LogicalDisk -Filter "DriveType = '3'" | | |
Select DeviceID, | |
VolumeName, | |
@{Name="FreeSpaceMB";Expression={[math]::Round($_.Freespace / 1mb)}}, | |
@{Name="SizeMB";Expression={[math]::Round($_.Size / 1mb)}} | |
# Get the running processes to x(ht)ml | |
$xml = [System.Xml.Linq.XDocument]::Parse( "$($disks | ConvertTo-Html)" ) |
View Get-DatabaseFileSpace.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-DatabaseFileSpace { | |
param ( | |
[string]$Instance = "LocalHost" | |
) | |
begin { | |
$svr = new-object ('Microsoft.SqlServer.Management.Smo.Server') $Instance | |
} #begin | |
process { | |
$dbfl = foreach ($db in $svr.Databases) { | |
$dbname = $db.Name |
View New-Report.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ReportHeader { | |
begin {} | |
process { | |
$computerSys = Get-WmiObject -Class Win32_ComputerSystem -Property Domain, Manufacturer, Model, Name | |
$rptHeader = @{ | |
ComputerName=$computerSys.Name | |
ComputerDomain=$computerSys.Domain |
View Create-HTMLTableInline.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get some data to work with | |
$procs = Get-Process | Select ProcessName, Id -First 5 | |
#Get the property values of each row using Value | |
$html = @" | |
<html> | |
<body> | |
$($procs | ConvertTo-Html -Fragment) | |
</body> | |
<html> |
NewerOlder