In az Get-AzScheduledQueryRule but in azurerm there is no query rule. I f any alternative script means pls share.
Well, the Get-AzScheduledQueryRule command gets the alert rule whose SIGNAL TYPE is Log Search, its resource type is microsoft.insights/scheduledqueryrules.
For the AzureRM module, your option is to use the Get-AzureRmResource command, specify the -ResourceType with "microsoft.insights/scheduledqueryrules".
Sample:
Get-AzureRmResource -ResourceGroupName "<ResourceGroupName>" -ResourceType "microsoft.insights/scheduledqueryrules" -Name "<alert rule name>" | ConvertTo-Json
Related
I'm trying to insert new row in my table storage by using Azure Cloud Shell but I'm facing below exception. So let me know any other command that we need to use to insert.
Blockquote
Add-AzTableRow: The term 'Add-AzTableRow' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Blockquote
Below are the command:
$partitionKey1 = "partition1"
$partitionKey2 = "partition2"
Add-AzTableRow `
-table $cloudTable `
-partitionKey $partitionKey1 `
-rowKey ("CA") -property #{"username"="Chris";"userid"=1}
According to the error, it seems that you do not install the module AzTable. Please run the command Get-InstalledModule to check if you have installed the module.
If you have not installed the module, please run the command Install-Module -Name AzTable -Force to install it.
For example
Install-Module -Name AzTable -Force
Import-Module AzTable
$resourceGroup = "<your group name>"
$storageAccountName ="<your account name>"
$storageAccount=Get-AzStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccountName
$ctx = $storageAccount.Context
$tableName = "<table name>"
$cloudTable = (Get-AzStorageTable –Name $tableName –Context $ctx).CloudTable
$partitionKey1 = "partition1"
Add-AzTableRow -table $cloudTable -partitionKey $partitionKey1 -rowKey ("CA") -property #{"username"="Chris";"userid"=1}
I analyse data from being sent multiple ZIP files.
They are always in this format:
service_SC30COM_####_20191130_1834.zip
#### is a random number generated by the computer.
Password is SC30COM_####, which is always part of the file name.
Any suggestions on an automation to unzip in bulk?
There is no way to do it on the command prompt without any application.
You can check this
If your remove the password, the code you need, as explain in that microsoft article should be:
$shell=new-object -com shell.application
$CurrentLocation=get-location
$CurrentPath=$CurrentLocation.path
$Location=$shell.namespace($CurrentPath)
$ZipFiles = get-childitem *.zip
$ZipFiles.count | out-default
foreach ($ZipFile in $ZipFiles)
{
$ZipFile.fullname | out-default
$ZipFolder = $shell.namespace($ZipFile.fullname)
$Location.Copyhere($ZipFolder.items())
}
If you install any application that can run on command prompt, you can extract with password. As example, for a individual file, the maximum you will get on Windows 10 is:
PowerShell Expand-Archive -Path "C:\Users\Tuffy\Desktop\PowerShell
Expand-Archive -Path "C:\Users\Whatever\Desktop\service_SC30COM_####_20191130_1834.zip"
-DestinationPath "C:\Users\Whatever\Desktop"p" -DestinationPath "C:\Whatever\Tuffy\Desktop"
Hope it helps!
You can run the following code as a bash script:
#!/bin/bash
for FILE in *.zip
do
echo "Unzipping $FILE ..."
PASSWORD=$(echo $FILE | grep -o -P '(?<=service_)[A-Za-z0-9]*_[0-9]*(?=_)')
unzip -P $PASSWORD $FILE
done
Copy the code
Paste it into FILENAME.sh
Make it executable (chmod +x FILENAME.sh)
Put it besides the zip files
Run it (./FILENAME.sh)
I am using linux terminal with below code to get server status but i am getting weblogic.Admin: command not found, any lead would be appreciable.
cd /opt/SP/WEB_DATA/weblogic/wls12130/user_projects/domains/pega/bin
. ./setDomainEnv.sh
export CLASSPATH=/WEB_DATA/weblogic/wls12130/wlserver/server/lib/weblogic.jar
ServerState=/opt/SP/WEB_DATA/mw/jdk1.8.0_91/bin/java weblogic.Admin -url http://t3://localhost:7001 -username weblogic -password weblogic1
GET -pretty -type ServerRuntime -property State |grep -i State|awk '{print $2}'| rev | cut -c 1- | rev
weblogic.Admin has been deprecated for a while now. Use wlst instead.
(location of ORACLE_HOME)/wlserver/common/bin/wlst.sh
wls:/offline>connect('weblogic','weblogic1','t3://localhost:7001')
wls:/DOMAIN/serverConfig>state('WLAdmin','Server')
WLAdmin is the name of the admin server
You can place the above commands in a python script and execute it using wlst
I am only using the new RM mode with PowerShell. Although I see all the storage cmdlets, but they do not seem to work with the classic storage accounts.
If I run these two commands, no account are returned:
Get-AzureRmSubscription –SubscriptionName "mysubs | Select-AzureRmSubscription
Get-AzureRmStorageAccount -ResourceGroupName "myrg"
Also....if I try this command:
Set-AzureRmStorageAccount -ResourceGroupName "myrg" -Name "myaccount" -Type Standard_GRS
It says no storage account exists. I think it is only looking for new storage accounts which I don't have any.
Is there a way to force the RM storage module to retrieve/manager classic storage accounts?
Regards
I don't think I can. So I used the following non-RM Cmdlts and it worked fine:
Add-AzureAccount
Select-AzureSubscription -SubscriptionName $subscription
Set-AzureSubscription -SubscriptionName $subscription -CurrentStorageAccountName $storageAccount
Get-AzureStorageBlob -Container $containerName
Get-AzureStorageBlob -Container $containerName | Export-Csv $csv -NoTypeInformation -Encoding UTF8 -Delimiter ','
I'm running the following command:
get-childitem C:\temp\ -exclude *.svn-base,".svn" -recurse | foreach ($_) {remove-item $_.fullname}
Which prompts me very frequently like this:
Confirm
The item at C:\temp\f\a\d has children and the Recurse parameter was not specified. If you continue,
all children will be removed with the item. Are you sure you want to continue?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
How can I have it automatically set to "A"?
The default is: no prompt.
You can enable it with -Confirm or disable it with -Confirm:$false
However, it will still prompt, when the target:
is a directory
and it is not empty
and the -Recurse parameter is not specified.
-Force is required to also remove hidden and read-only items etc.
To sum it up:
Remove-Item -Recurse -Force -Confirm:$false
...should cover all scenarios.
Add -confirm:$false to suppress confirmation.
Try using the -Force parameter on Remove-Item.
Add -recurse after the remove-item, also the -force parameter helps remove hidden files
e.g.:
gci C:\temp\ -exclude *.svn-base,".svn" -recurse | %{ri $_ -force -recurse}
Remove-Item .\foldertodelete -Force -Recurse
Just an additional tip:
Let's say the PS1 (helloworld.ps1) has a code like below:
Set-ExecutionPolicy Unrestricted -Confirm:$false -Force
Write-Host "Hello, World!"
And if we expect that each time the code runs, it would automatically run the Set-ExecutionPolicy without prompting the user & run the code silently...
It won't work that way!! I'm still figuring out how to run a PS code without prompting the user & will post the solution if I find out
You just need to add a /A behind the line.
Example:
get-childitem C:\temp\ -exclude *.svn-base,".svn" -recurse | foreach ($_) {remove-item $_.fullname} /a