Azure KeyVault: Retrieve secrets and their values using PowerShell and save in Excel file

 

Azure KeyVault: Retrieve secrets and their values 

using PowerShell and saving in Excel file


$vault_name="keyvault-name"


$excel = New-Object -ComObject excel.application
$workbook = $excel.Workbooks.Add()



$uregwksht= $workbook.Worksheets.Item(1)
$uregwksht.Name = $vault_name
$row = 1
$Column = 1
$uregwksht.Cells.Item($row,$column)= "Secret-Name"
$uregwksht.Cells.Item($row,$column+1)= "Secret-Value"

# Get all secret names
$secret_names=$(az keyvault secret list --vault-name $vault_name --query [].name -o tsv)


# Loop through each secret name and get its value
foreach ($secret in $secret_names)
  $secret_value=$(az keyvault secret show --vault-name $vault_name --name $secret --query "value")
   
  Write-Output $row
  
  $row = $row + 1 
  $uregwksht.Cells.Item($row,1)= $secret
  $uregwksht.Cells.Item($row,2)= $secret_value
  
  #if ($row -eq 2) { break }
    
  # Write-Output $secret
  # Write-Output $secret_value 
  # Write-Output "-------------------------"
}



$outputpath = "D:\"+ $vault_name + ".xlsx"

Write-Output $("File saved on " + $outputpath )

$excel.displayalerts = $false
$workbook.Saveas($outputpath)
$excel.displayalerts = $true


$excel.Quit()  


Azure KeyVault: Retrieve secrets and their values

 Azure KeyVault: Retrieve secrets and their values 

using PowerShell



$vault_name  = "keyvault-name"


# Get all secret names

$secret_names=$(az keyvault secret list --vault-name $vault_name --query [].name -o tsv)


# Loop through each secret name and get its value

foreach ($secret in $secret_names)

  $secret_value=$(az keyvault secret show --vault-name $vault_name --name $secret --query "value")   

  Write-Output $secret

  Write-Output $secret_value 

  Write-Output "-------------------------"

}


Create an Excel file using PowerShell script

Create an Excel file using PowerShell script 


Here is a code to write data into Excel file and save it in a particular path.

$excel = New-Object -ComObject excel.application

#$excel.visible = $True

$workbook = $excel.Workbooks.Add()

$SheetName = "MySheet"

$uregwksht= $workbook.Worksheets.Item(1)

$uregwksht.Name = $SheetName


$row = 1

$Column = 1

$uregwksht.Cells.Item($row,$column)= "Column Title"


for ($i = 2; $i -le 5; $i++)

{

    Write-Output $i

  $row = $row + 1

  $uregwksht.Cells.Item($row,$column)= "Abcd" + $i

}

$outputpath = "D:\test.xlsx"

$excel.displayalerts = $false

$workbook.Saveas($outputpath)

$excel.displayalerts = $true

Write-Output $("File saved on " + $outputpath )

$excel.Quit()


#ref - https://community.spiceworks.com/t/create-an-excel-file-from-within-powershell/1011485

#ref - https://chanmingman.wordpress.com/2022/10/02/powershell-write-to-excel-file/

React Native - Call API on Button Click

 

React Native - Call API on Button Click


import React from 'react';
import { View, Text, Button, TouchableOpacity,Alert }from 'react-native';
const App = () => {
 
 const handleLogin = async() => {
  let resp= await fetch('https://api.demo.com/api/Data/GetDestination');
  let respjson = await resp.json();
  console.log(respjson);
  Alert.alert("msg", "123");
}
   
    return(
      <View>
        <Text style={{fontSize:70}}>
       Call Api
        </Text>    
        <Button onPress={handleLogin}
          title="Learn More"
          color="#841584"
          accessibilityLabel="Learn more about this purple button"
        />

      <TouchableOpacity>
        <Text onPress={handleLogin}>Login</Text>
      </TouchableOpacity>

      </View>
    )
  }

export default App

docker build sh: react-scripts: not found

 docker build sh: react-scripts: not found


Issue

 docker build sh: react-scripts: not found


Solution

Deleting package-lock.json and re-installing packages with npm install before building the container solved the issue for me.


Hope this will help you and save your time.

Enjoy !!!

:)

Data is Null. This method or property cannot be called on Null values

 Data is Null. This method or property cannot be called on Null values

Issue: 

Data is Null. This method or property cannot be called on Null values


Solution:

For columns that are nullable in your DB tables:

Wrong

 public string Memo { get; set; }

Correct: 

 public string? Memo { get; set; }


Hope this will help you and save your time.

Enjoy !!!

:)

The term 'New-AzResourceGroup' is not recognized as the name of a cmdlet, function, script fiel or operable program.

 The term 'New-AzResourceGroup' is not recognized as the name of a cmdlet, function, script fiel or operable program.

Issue:

New-AzResourceGroup : The term 'New-AzResourceGroup' 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.

At line:1 char:1

+ New-AzResourceGroup

+ ~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (New-AzResourceGroup:String) [], CommandNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException


Solution:

You need to install the Azure Powershell module:

You can look for just the one for this command:

Install-Module -Name Az.Resources -AllowClobber -Scope CurrentUser

Or all of them:

Install-Module -Name Az -AllowClobber -Scope CurrentUser


Hope this will help you and save your time.

Enjoy !!!

:)