Based on the info I found here, this one-liner is a quick way of displaying a Windows system’s uptime from the command prompt…
net stats srv | find "since"
Results in the following:
Statistics since 16/05/2013 2:32:48 PM
Based on the info I found here, this one-liner is a quick way of displaying a Windows system’s uptime from the command prompt…
net stats srv | find "since"
Results in the following:
Statistics since 16/05/2013 2:32:48 PM
Had an issue on some new Server 2012 Hyper-V clustered hosts. Started seeing the following error in the logs:
Cluster Shared Volume 'SERVERNAME' ('') has identified one or more active filter drivers on this device stack that could interfere with CSV operations. I/O access will be redirected to the storage device over the network through another Cluster node. This may result in degraded performance. Please contact the filter driver vendor to verify interoperability with Cluster Shared Volumes.
Active filter drivers found:
???????????????????????
Yes, those are random characters in the error message, so it’s difficult to track down the filter driver in question.
This seems to match the same issue in Server 2008 R2 – Redirected mode is enabled unexpectedly in a Cluster Shared Volume when you are running a third-party application in a Windows Server 2008 R2-based cluster
In the Microsoft KB notes, they state one of the conditions as being:
Running fltmc.exe on these hosts shows the following filter drivers loaded:
The filter driver with the decimal point is stcvsm, the “StorageCraft Volume Snapshot Driver” The problem has only been occurring recently, after I installed ShadowProtect.
I’ve had to uninstall ShadowProtect from these servers until it’s officially supported on Server 2012. According to StorageCraft, that should be 90 days after the official launch date of Server 2012. That means there should be a new version of ShadowProtect around the 3rd of December 2012.
I’m sure there’s a better way of doing this, but here’s how I captured the output of SQL’s bcp.exe in order to email it and the CSV that we were creating automatically on a schedule overnight.
I ended up piping the executable to a temp file, and then grabbing the contents of that same temp file to populate the email body. Here are the lines in question:
&$exe $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 > c:\temp\out.txt $bcpOutput = Get-Content c:\temp\out.txt | Out-String Remove-Item c:\temp\out.txt
Here’s the script in its entirety:
# This needs to be set, otherwise Send-MailMessage doesn’t have a server to send through$PSEmailServer ="mailserver.local"
$PSEmailServer ="mailserver.local"
$emailRecipient = "Daniel <daniel@contoso.com>"
# Some date and filename related stuff. This part's not important
$d = Get-Date
$yesterday = $d.AddDays(-1)
$filepath = "C:\Exports\SQL Export\"
$filename = "SQL-DailyExport-{0}.{1}.{2}.csv" -f $yesterday.Day,$yesterday.Month,$yesterday.Year
$fullpath = $filepath + $filename
# Path to the executable
$exe = "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\bcp.exe"
# arguments, as required
$arg1 = "DBName..ViewName"
$arg2 = "out"
$arg3 = $fullpath
$arg4 = "-c"
$arg5 = "-t,"
$arg6 = "-T"
# Run the executable with the arguments, and pipe the STDOut output to a text file
&$exe $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 > c:\temp\out.txt
# An intro line for the body of the email
$bcpOutput = "SQL daily export process information: `r`n"
# Get the contents of the temporary file that we created earlier
$bcpOutput += Get-Content c:\temp\out.txt | Out-String
# Remove the temporary file
Remove-Item c:\temp\out.txt
# Build up our subject line. This part's not important
$subjectText = "SQL export for {0}/{1}/{2}" -f $yesterday.Day,$yesterday.Month,$yesterday.Year
# Append some more information to the end of the body text. Again, not important
$bcpOutput += "`r`nThe output file is attached, and can also be found in \\sql\Exports"
# Send the email with the file attached and the body text as we've built it up
Send-MailMessage -From "SQL Export <Process@sql.server>" -To $emailRecipient -Subject $subjectText -Body $bcpOutput -Attachments $fullpath
This results in an email that contains the output from bcp.exe as well as the actual SQL export file attached to the email.
Recently had to convert a batch file that calls bcp.exe to a more involved PowerShell script. The script exports the contents of a view to CSV format.
I originally had some issues getting the command line arguments to work, but here’s how I got it working:
$fullpath = c:\temp\out.csv $exe = "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\bcp.exe" $arg1 = "DBName..ViewName" $arg2 = "out" $arg3 = $fullpath $arg4 = "-c" $arg5 = "-t," $arg6 = "-T" &$exe $arg1 $arg2 $arg3 $arg4 $arg5 $arg6
Had a user today that was receiving an NDR when trying to send as another user. This was strange as this user has always had full mailbox access and send-as permissions to the mailbox in question, so the NDR was unexpected.
It turned out to be an issue with cached address entries when typing the sender’s address into the “From” field in Outlook. I removed all of the relevant entries and then resolved the sender from the address book, and the email went through without any issues.
One for the memory banks…