Skip to content

Instantly share code, notes, and snippets.

Daniel Streefkerk dstreefkerk

Block or report user

Report or block dstreefkerk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dstreefkerk
dstreefkerk / Get-WeekNumber.ps1
Created Aug 27, 2015
A simple PowerShell function to return the week number for a given date using the current globalisation culture.
View Get-WeekNumber.ps1
function Get-WeekNumber([datetime]$DateTime = (Get-Date)) {
$cultureInfo = [System.Globalization.CultureInfo]::CurrentCulture
$cultureInfo.Calendar.GetWeekOfYear($DateTime,$cultureInfo.DateTimeFormat.CalendarWeekRule,$cultureInfo.DateTimeFormat.FirstDayOfWeek)
}
View Manage-WifiStatus.ps1
#Requires -Version 4.0 -RunAsAdministrator
<#
.SYNOPSIS
Manage-WiFiStatus.ps1 - Enable/Disable WiFi based on wired connectivity status
.DESCRIPTION
Disables the Wi-Fi adapter if the wired one is connected, and vice versa.
This is built for internal use on Windows 8.1, and depends on the new *-NetAdapter cmdlets in PS 4.0
View Get-ProliantTemperatures.ps1
#requires -version 3
<#
.SYNOPSIS
Get-ProliantTemperatures - Get HP ProLiant temperature sensor readings and status for PRTG
.DESCRIPTION
Reads the status of HP ProLiant temperatures sensors via WMI and HP WBEM
and
http://www.hp.com/go/HPwbem
@dstreefkerk
dstreefkerk / Migrate-OfficescanClient.ps1
Created May 2, 2014
Computer startup or PS Remoting script to migrate an installed Officescan client to another server if it's currently pointed at a different one.
View Migrate-OfficescanClient.ps1
<#
.SYNOPSIS
Migrate-OfficescanClient - Migrate Officescan clients to the correct server
.DESCRIPTION
Checks which server the Officescan client is pointing to (by reading ofcscan.ini)
If it's pointing to the wrong one, call the appropriate ipxfer command with
the correct parameters to point it to the new/correct server
@dstreefkerk
dstreefkerk / Remove-FilesiteViews.ps1
Created Nov 21, 2014
Remove VDM files for all users, for HP FileSite for Outlook
View Remove-FilesiteViews.ps1
<#
.SYNOPSIS
Remove-FilesiteViews.ps1 - Remove VDM files for all users
.DESCRIPTION
This script is designed to be run under the SYSTEM account, as it needs
access to every user's profile. This will work fine as a scheduled task, or
under SCCM or similar.
As per the release notes for Filesite 9.0 Update 5, all VDM files need to be deleted
@dstreefkerk
dstreefkerk / Spiceworks_Geckoboard-TicketsOpen.ps1
Created Dec 5, 2014
Tickets Open widget update code. To be used with a "Number and Secondary Stat" widget: https://developer.geckoboard.com/#number-and-secondary-stat
View Spiceworks_Geckoboard-TicketsOpen.ps1
$apikey = "paste in your API key here"
$geckoPushUrl = "paste in your push URL here"
# Get the count of open tickets from the database
$openTickets = Invoke-Item spiceworks: -sql 'select count() as "count" from tickets where status == "open"'
#Construct a here-string with the required json format
$jsonstream = @"
{
"api_key":"APIKEY",
@dstreefkerk
dstreefkerk / Spiceworks_Geckoboard-TicketList.ps1
Created Dec 5, 2014
Ticket List Widget update code, to be used with a List Widget: https://developer.geckoboard.com/#list
View Spiceworks_Geckoboard-TicketList.ps1
$query = @"
select t.id as id,t.summary as summary,t.description as description,u.first_name || ' ' || u.last_name as name, round((julianday(date('now','localtime')) - julianday(t.created_at))) + 1 as days, t.category as category from tickets as t
inner join users as u on t.created_by = u.id
where status == 'open'
order by t.created_at desc
"@
$apikey = "paste API key here"
$geckoPushUrl = "paste push URL here"
@dstreefkerk
dstreefkerk / Update-GeckoboardDashboard.ps1
Created Dec 5, 2014
Spiceworks Geckoboard Wrapper Script
View Update-GeckoboardDashboard.ps1
Import-Module sqlite
$scriptLocation = "C:\Scripts\Spiceworks-Geckoboard\"
$spiceworksDatabaseFilePath = "C:\Program Files (x86)\Spiceworks\db\spiceworks_prod.db" # Path to the SQLite database used by SpiceWorks
# Get all of the widget scripts
$allScripts = Get-ChildItem $scriptLocation -Filter "*.ps1"
# Mount the SpiceWorks database
mount-sqlite -name SpiceWorks -dataSource $spiceworksDatabaseFilePath
@dstreefkerk
dstreefkerk / Get-ChicagoCrimes.ps1
Created Apr 23, 2015
Retrieves data from https://data.cityofchicago.org and shows the last 1 month's crime data
View Get-ChicagoCrimes.ps1
# Get the data, convert it to JSON
$jsonData = Invoke-WebRequest "https://data.cityofchicago.org/resource/ijzp-q8t2.json" | ConvertFrom-Json
# Filter our data set down to only the last month's crimes. Note that the data feed has a built-in lag of 7 days
$lastMonthsData = $jsonData | Where-Object {($_.date | get-date) -gt ((get-date).AddMonths(-1))}
# Show results, allowing user to select categories first and then view individual crimes
$lastMonthsData | Group-Object -Property primary_type | Sort-Object Count -Descending | Select-Object Name,Count,Group | Out-GridView -Title "Select a category (or multiple) to view details" -OutputMode Multiple | Select-Object -ExpandProperty Group | select primary_type,description,location_description,date,latitude,longitude,block,domestic,arrest,case_number | Sort-Object date -Descending | Out-GridView -Title "Crime Details"
@dstreefkerk
dstreefkerk / Spiceworks to FreshDesk - Contacts
Created Jul 9, 2015
SQLite query to extract users from Spiceworks' DB for tickets created in the past 2 years and get it into the format required by FreshDesk for contact import via CSV
View Spiceworks to FreshDesk - Contacts
select distinct u.email as email,
u.first_name || ' ' || u.last_name as name,
u.title as job_title,
u.cell_phone as mobile,
u.office_phone as phone,
u.location as time_zone,
'en' as language
from users as u
inner join tickets as t on u.id = t.created_by
where (u.disabled is null) and ((u.first_name is not null) and (u.last_name is not null))
You can’t perform that action at this time.