Wednesday, May 30, 2018
YouTube content to Twitter posts with PowerShell & Time Triggered Azure Function
YouTube content to Twitter posts with PowerShell & Time Triggered Azure Function
https://ridicurious.com/2018/05/29/youtube-to-twitter-posts-using-azure-functions/
Batch file to create backups of files to remote network paths using date and time stamps
Robocopy example
rem batch file to create backups of files to remote network paths using date and time stamps
FOR /f "tokens=1-5 delims=/- " %%a in ('date /t') DO SET XDate=%%d%%b%%c
FOR /f "tokens=1-5 delims=/- " %%a in ('date /t') DO SET XSDate=%%d%%b
FOR /f "tokens=1-2 delims=: " %%a in ('time /t') DO SET XTime=%%a%%b
Echo "%XSDate%\%XDate%\%XDate%_%XTime%"
set PW=Somepass1@@
set USR=Install
rem set SOUPATH=Internal
set SOUPATH=Dev_Local
rem set LAB=DSCLIVE
set LAB=DSCLAB
set ROLE=DC1
net use M: \\%Lab%%Role%\c$\%SOUPATH% %PW% /user:%usr%
Robocopy C:\Dev_Local M:\Backup\Code_Backup\%Lab%_%XDate%_%XTime%\%Lab%%Role% *.* /S /Z /XF *.EXE *.MSI *.ISO
net use m: /delete
How to Create Encrypted Zip or 7z Archives on Any Operating System
How to Create Encrypted Zip or 7z Archives on Any Operating System
https://www.howtogeek.com/203590/how-to-create-secure-encrypted-zip-or-7z-archives-on-any-operating-system/
Monday, October 31, 2016
Tweaks to Write-LogEntry
Tweaks to Write-LogEntry that was posted to Twitter by Trevor Sullivan @pcgeek86
His original PowerShell code:
function Write-LogEntry {My tweaks to the original PowerShell code:
[CmdletBinding()]
param (
[string] $Message,
[string] $Severity
)
$CallStack = Get-PSCallStack
$LogMessage = '{0} {1}: {2}: {3}' -f (Get-Date -Format u), $CallStack[1].FunctionName, $Severity, $Message
Add-Content -Path c:\temp\logfile.log -Value $LogMessage
}
function LogTester {
[CmdletBinding()]
param (
)
Write-LogEntry -Message Testing1 -Severity Information
Write-LogEntry -Message Testing2 -Severity Warning
Write-LogEntry -Message Testing3 -Severity Error
}
LogTester
Function Write-LogEntry {I did the following:
[CmdletBinding()]
param (
[string] $Message,
[string] $Severity,
[string] $Step
)
$CallStack = Get-PSCallStack
$LogMessage = '{0},{1},{2},{3},{4},{5}' -f $env:computername,((get-date).ToUniversalTime()), $CallStack[1].FunctionName, $Severity, $Message, $Step
Add-Content -Path c:\temp\logfile.csv -Value $LogMessage
}
function LogTester {
[CmdletBinding()]
param (
)
Write-LogEntry -Message Testing1 -Severity Information -Step 10
Write-LogEntry -Message Testing2 -Severity Warning -Step 20
Write-LogEntry -Message Testing3 -Severity Error -Step 55
}
LogTester
Changed the format of the date to UTC that was readable by Excel
Changed the output to a .CSV format and adding commas to the -f
Added the computername as the first entry in the text log
Added a parameter Step to the log
When I am consuming logs, lots of logs, I like tools like Excel to slice, dice, sort, and filter the data for me in a visual way.
When I write logging functions, I like to know what step tripped the log entry. So in my applications I set $Step to a number that is incremental from the last step I used this variable.
For example I set my step to 10 for the variable initially at the beginning of the application. Then at the start of each major piece of logic where I could trip the logging I increment the step by 10.
The steps then help me narrow down where in code the logging got tripped.
A future version of this could be to load the log into a SQL Table and also account for multiple applications writing to the same log.
Thank Trevor !!
Friday, April 1, 2016
Scaling DSC - Desired State Configuration in PowerShell
How to Scale DSC - Desired State Configuration in PowerShell
This series of posts will cover my ideas of how to scale DSC beyond just a few servers or VM's.
Make the servers cattle, not pets.
But when you have to scale this DevOps process to 10's, 100's, or 1000's of servers, writing code for each server and configuration does not scale.
Data Driven
PowerShell can help generate the DSC code necessary to scale and make DSC data driven.
Why Data Driven?
A common deployment scenario is you want to create a small scale SharePoint farm of one SQL Server, one front end web server, and one App server.
The server for SQL has to be created and configured first, then web and App.
Each server type has different requirement for creation and configuration.
Using DSC manually, you have to remember the order of deployment and many attributes for each server type.
DSCDB can treat this farm as a collection (example Collection_SPsmall). Multiple collections can be created or cloned into a collection library.
It can know in what order the servers have to be deployed, and almost all the attributes that need to be passed to DSC to create MOFs including credentials.
In order to deploy using DSCDB, you only need the name of the server set (example SPsmall_1) and optionally a few additional parameters. The server set uses the collection (Collection_SPsmall) to know the farm configuration.
The deployment can then run either sequentially or in parallel.
The Scaling DSC Series
A DSCDB is a simple set of tables in a database that is used to capture attributes about each server that is needed for deployment.
#2 Populating a DSCDB
There are four ways to populate the database:
- Importing an Excel file of server names and attributes
- Importing a text file of server names
- Importing server names from AD - Active Directory
- Manually update the SQL tables
#3 Deploying using DSCDB
This post will talk about how to deploy servers in a automated fashion using the DSCDB.
#4 Future Features for DSCDB
This post will discuss potential features for future releases.
Conclusion
This database is not a CMDB but a database specifically designed for deployment using DSC.
All the source code and documentation for this series will be in Github.
Wednesday, August 19, 2015
Windows Server 2016 Technical Preview 3 released with Windows Container support http://t.co/Pl15JJRtbd #container #winserv
Windows Server 2016 Technical Preview 3 released with Windows Container support http://t.co/Pl15JJRtbd #container #winserv
— Dusty R (@nakedpowershell) August 20, 2015
from Twitter https://twitter.com/nakedpowershell
Monday, August 17, 2015
How BitTorrent could let lone DDoS attackers bring down big sites http://t.co/yCMMDIDWJB #infosec #security
How BitTorrent could let lone DDoS attackers bring down big sites http://t.co/yCMMDIDWJB #infosec #security
— Dusty R (@nakedpowershell) August 17, 2015
from Twitter https://twitter.com/nakedpowershell
Subscribe to:
Posts (Atom)