proxb / powershell_scripts Goto Github PK
View Code? Open in Web Editor NEWMiscellaneous scripts for things that I have done; more scripts will arrive as I get time to update this repo.
License: MIT License
Miscellaneous scripts for things that I have done; more scripts will arrive as I get time to update this repo.
License: MIT License
I made the script for a notification balloon that was gonna be in my Crazy Error, but there is a part of the script that is causing me problems (see image below, squared part is the script that causes me problems):
I try to run the script, and I get this (see image below):
What is happening and how do i fix it?
hello,
I'm running various instances of ms sql (including database engine, reporting, analysis, ...),
I was getting the following exception:
You cannot call a method on a null-valued expression.
At C:\xxx\Get-SQLInstance.ps1:185 char:25
+ $PropertyHash['Version'] = $instanceRegSetup.GetValue('V ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
I added some debug: https://github.com/chipitsine/PowerShell_Scripts/blob/master/Get-SQLInstance.ps1#L182
here's more detailed exception
computer: SRV-SQL01-DCA
file: "C:\Program Files\Microsoft SQL Server\MSAS11.DEV_DCA\OLAP\bin\msmdsrv.exe" -s "H:\OLAP\Config"
service: "C:\Program Files\Microsoft SQL Server\MSAS11.DEV_DCA\OLAP\bin\msmdsrv.exe" -s "H:\OLAP\Config"
Something went wrong...
System.ArgumentException
Illegal characters in path.
You cannot call a method on a null-valued expression.
At C:\xxx\Get-SQLInstance.ps1:198 char:25
+ $PropertyHash['Version'] = $instanceRegSetup.GetValue('V ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
it seems, script does not expect MSAS ?
This is a very useful PS script so thank you greatly to the creator/contributors. It would just be even better if I could get the sAMAccountName out of it. Is this possible?
Computername : SRV-SQL02-DCA
Instance : {MSSQL$DEV_DCA, MSSQL$HFM_DCA, MSSQL$INF_DCA, MSSQL$IPORT_DCA...}
SqlServer : SRV-SQL-TFS
WMINamespace : ComputerManagement12
Sqlstates : 2099213
Version : 12.0.2000.8
Splevel : 0
Clustered : True
Installpath : C:\Program Files\Microsoft SQL Server\MSSQL12.WHD\MSSQL
Datapath : S:\MSSQL12.WHD\MSSQL
Language : 1033
Fileversion : 2014.120.2000.8
Vsname : SRV-SQLWHD-DCA
Regroot : Software\Microsoft\Microsoft SQL Server\MSSQL12.WHD
Sku : 1804890536
Skuname : Enterprise Edition (64-bit)
Instanceid : MSSQL12.WHD
Startupparameters : -dS:\MSSQL12.WHD\MSSQL\DATA\master.mdf;-eS:\MSSQL12.WHD\MSSQL\Log\ERRORLOG;-lS:\MSSQL12.WHD
\MSSQL\DATA\mastlog.ldf
Errorreporting : False
Dumpdir : S:\MSSQL12.WHD\MSSQL\LOG\
Sqmreporting : False
Iswow64 : False
BackupDirectory : S:\MSSQL12.WHD\MSSQL\Backup
AlwaysOnName :
Nodes : {SRV-SQL01-DCA, SRV-SQL02-DCA, SRV-SQL03-DCB}
Caption : SQL Server 2014
FullName : SRV-SQL-TFS\System.Object[]
PowerShell_Scripts/Invoke-BalloonTip.ps1
Line 46 in 65d0ac8
This object type doesn't work here. The assembly is loaded later so this produces an error.
To resolve just remove this from the parameter as the object type is set later in this line
PowerShell_Scripts/Invoke-BalloonTip.ps1
Line 78 in 65d0ac8
The following error pops up several times while the script is processing:
Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null.
Yet it seems like it's exporting to a CSV ok despite the above error.
Set-Owner does not work on PowerShell 6 due to referencing .NET Framework assembly APIs. .NET Core has refactored these APIs, and they no longer work in PowerShell 6 because the API is not there.
The following is a simpler Set-Owner script:
#
# IMPORTANT: Run with ELEVATION
#
# The target folder.
$folder = 'C:\Temp'
# Specify the new owner, which can be a mere username ('John.Doe'), a well-known
# security principal ('BUILTIN\Administrators'), or a UPN ('[email protected]')
$newOwner = 'BUILTIN\Administrators'
# Get the current ACL...
$acl = Get-Acl -LiteralPath $folder
# ... and assign the new owner...
$acl.SetOwner([System.Security.Principal.NTAccount] $newOwner)
# ... and set the modified ACL.
Set-Acl -LiteralPath $folder -AclObject $acl
"New owner: $((Get-Acl -LiteralPath $folder).Owner)"
When I run the script in ISE it works perfectly, but when I save it as a .PS1 I get:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Unable to find type [System.Windows.Forms.ToolTipIcon].
At C:\scripts\password\Password_Notify.ps1:37 char:9
[System.Windows.Forms.ToolTipIcon]$MessageType="Info",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hello! Good work!
How about long path support?
Hi Great work saved me some time ;-)
But it took me some time as AUOptions did never got higher than 3 in the registry.
Also got the message that automatic downloads are disabled.. (w10 21H1)
Looks like NoAutoUpdate needs to be reversed..
here I have some enhancements for that issue's
The following " } ElseIf ($Options = " should be " } ElseIf ($Options -eq"
That way "AUOptions" can get higher than 3 ;-)
Line 223,225 and 227
If ($PSBoundParameters['Options']) {
If ($pscmdlet.ShouldProcess("Options","Set Value")) {
If ($Options -eq 'Notify') {
$WsusConfig.SetValue('AUOptions',2,[Microsoft.Win32.RegistryValueKind]::DWord)
} ElseIf ($Options = 'DownloadOnly') {
$WsusConfig.SetValue('AUOptions',3,[Microsoft.Win32.RegistryValueKind]::DWord)
} ElseIf ($Options = 'DownloadAndInstall') {
$WsusConfig.SetValue('AUOptions',4,[Microsoft.Win32.RegistryValueKind]::DWord)
} ElseIf ($Options = 'AllowUserConfig') {
$WsusConfig.SetValue('AUOptions',5,[Microsoft.Win32.RegistryValueKind]::DWord)
}
}
}
Then there is an mistake at: AllowAutomaticUpdates starting from line 310.
When Enabled it enables NoAutoUpdate to 1, when I do this at Windows10 21H1 it says automatic updates disabled.
changing it to 0, NoAutoUpdate to 0 and that message Disappears .
So I changed 313 and 317 1to0 and 0to1.
Hope it helps someone else.
Anyway keep up the good work!.
Arnold.
hello,
I've writter simple script
cls
. "C:\xxx\Get-SQLInstance.ps1"
'running on: {0}' -f $env:Computername
'---------------'
Get-SQLInstance -Computername $env:Computername | % {
$_.ComputerName
}
I expected it to show cluster node (an owner of cluster application). However, it shows current computer all the time:
running on: SRV-SQL01-DCA
---------------
SRV-SQL01-DCA
SRV-SQL01-DCA
SRV-SQL01-DCA
SRV-SQL01-DCA
SRV-SQL01-DCA
SRV-SQL01-DCA
SRV-SQL01-DCA
SRV-SQL01-DCA
SRV-SQL01-DCA
SRV-SQL01-DCA
SRV-SQL01-DCA
PS C:\Windows\system32>
actually, I checked, cluster instances are distributed across several nodes.
there's another Get-SQLInstance (which is not very usable because of mandatory "Credential")
https://technet.microsoft.com/en-us/library/mt759805.aspx
please, rename Get-SQLInstance commandlet
(we agreed on that in email conversation, I open an issue to keep it in mind)
I work in a DevOps heavy environment where there are a lot of machines that do not get joined into the Domain because they are torn down after their smoke-tests are run. Or that's what they tell me is supposed to happen...
In reality though a good number of these machines persist and get passed around from dev to dev. That creates an issue of needing non-domain credentials to pull ADSI information from the remote host.
How could we facilitate that use case with the script? Would it need to be a new fork entirely or could it be added in?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.