How to read who created lists on Sharepoint - sharepoint

I am new to Sharepoint, but I need to get a list of files from my Sharepoint site and determine who created the file. Is there a way to do this? I have been looking online for the last couple of hours and found some Power shell scripts. But when I run them I get errors.
First thing I did was install Microsoft.Online.Sharepoint.Powershell
I ran the script :
Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version
I got
Name Version
Microsoft.Online.SharePoint.PowerShell 16.0.21909.0
So it looks like I installed it correctly.
I ran the script
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
I got the error
Install-Module : The 'Install-Module' command was found in the module 'PowerShellGet', but the module could not be
loaded. For more information, run 'Import-Module PowerShellGet'.
At line:1 char:1
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
+ CategoryInfo : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
Is there something else I need to load ? Or this is the wrong direction to get the information?

You could run the following Powershell commands: Set-ExecutionPolicy Unrestricted then try to run Install-Module -Name Microsoft.Online.SharePoint.PowerShell again.
For Reference: Set-ExecutionPolicy.

Related

Unable to install AzureAd module using Install-Module -Name AzureAD in ADO pipeline

I am trying to execute Get-AzureADServicePrincipal in a azure powershell task in ADO.
I need to get service principal for me to then connect to get ServicePrincipalId and ServicePrincipalkey.
As part of this I am trying the below, as an inline script
Install-Module -Name AzureAD
Get-AzureADServicePrincipal
But this keeps failing as,
WARNING: User declined to install module (AzureAD)
[error]The term 'Get-AzureADServicePrincipal' is not recognized as the name of a cmdlet
Please could some one help? Thanks
Install-Module is prompting for user input. Specify the -Force flag.
If you are using host agent. Better to install a module only for the current user
This example downloads and installs the newest version of a module, only for the current user. Also add -Force
Install-Module -Name PowerShellGet -Scope CurrentUser -Force
Then you need to call the Connect-AzureAD cmdlet before calling any other cmdlets.
Finally Get-AzureADServicePrincipal.

Installing Azure Module on an AWS instance using userdata

I'm trying to automatically install the Azure module for PowerShell (Az) on an AWS EC2 instance through userdata so Azure commands can be executed when an instance is started. However, I'm getting this error:
PackageManagement\Install-Package : Cannot convert value
"2.0.0-preview" to type "System.Version". Error: "Input string was
not in a correct format."
Other people who have reported this problem have solved it by upgrading PowerShellGet and removing the old version. I'm doing that with this block of code:
Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 -Force -Confirm:$false
Install-Module -Name PowerShellGet -Repository PSGallery -Force -Confirm:$false
Remove-Item -Path "C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1" -Force -Recurse
However when I run the command to install the moudule after that:
Install-Module -Name Az -AllowClobber -Force -Confirm:$false -Scope AllUsers
I still get the same error.
How can I fix this without having to close and reopen the shell? This all needs to run as part of the same script.
You used Remove-Item, however that command just deleted the module file. The imported module still existed in your PS session. So, you may try to use Remove-Module remove it and use Import-Module to import the right one. But, this is not the suggested way, you may try the following two approaches:
You can just use Update-Module -Name PowerShellGet -Force to directly update your existing module.
Another way is to uninstall your old module, and then install the new version.

The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program

Created Powershell Azure function and trying to use "az" commands under that function app. As per docs, function runtime should resolve "az" and other module dependencies. but it doesn't work for me.
ERROR: The term 'az' 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.
Microsoft.Azure.WebJobs.Script.Rpc.RpcException : Result: ERROR: The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program.
I want to run some "az" command under function app without manually uploading modules. Is it powershell Preview version issue or something I need to correct?
requirement.psd1
#{
Az = '2.*'
}
For those who get these error in local while trying to access AZ, try this command below in an admin PowerShell instance.
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi
You can get more details about installation # https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest&tabs=azure-powershell
Make sure you restart the powershell instance
"Az" in the context of PowerShell probably means the Az module, with cmdlets like Add-AzAccount etc.
"az" is the cross-platform CLI, which is not a PowerShell module.
I got this error because I had not installed CLI. I was sent this link which downloaded the required install:
https://aka.ms/installazurecliwindows
Two ways you can solve this issue.
Install below installation file for Azure CLI in windows.
https://aka.ms/installazurecliwindows
(OR)
Install using PowerShell the below command.
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi
More details: https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest&tabs=azure-cli
I can see PowerShell 7.x and later is the recommended version.
You can check Powershell version using below command
$PSVersionTable.PSVersion
https://learn.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-6.2.0
NOTE
PowerShell 7.x and later is the recommended version of PowerShell for
use with the Azure Az PowerShell module on all platforms.
Run this to fix:
Install-Module AzureAD -Force
Install-module AzureADPreview -Force
Install-Module -Name MSOnline -Force
Import-Module Az -Force
Install-Module Az -Force
Download this then this problem will not occur.
https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli

Connect-AzureRMAccount : The term 'Connect-AzureRMAccount' is not recognized as the name of a cmdlet, function, script file, or operable program

I am stuck in a problem in Azure PowerShell. I am not able to connect to AzureRM account. It's showing this error:
Connect-AzureRMAccount : The term 'Connect-AzureRMAccount' 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
+ Connect-AzureRMAccount
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-AzureRMAccount:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I'm doing this in Mac OS . Firstly I've installed the PowerShell using: brew cask install PowerShell.
Then I've done the following:
Install-Module AzureRM -AllowClobber -Scope CurrentUser.
Install-Module Azure.
Install-Module AzureRM.
Import-Module AzureRM.
Connect-AzureRMAccount (It's Showing me the above Error).
I am expecting step 5 to give me the sign in pop up. Please Help
The AzureRM module isn't available on macOS. You will need the Az module. It has tons of parity and an option for enabling compatible aliases (Enable-AzureRmAlias):
https://azure.microsoft.com/en-us/blog/azure-powershell-cross-platform-az-module-replacing-azurerm/
Keep in mind that this module is the future, in general (Windows, macOS, and Linux... as well in Azure Cloud Shell).
The following cmdlets are useful:
Install-Module -Name Az -AllowClobber
Import-Module Az
Connect-AzAccount

Export Azure App Service Certificate as .pfx on Mac

What is the easiest way to export an Azure App Service Certificate on Mac?
All results seem to point to Powershell - I have attempted to install Powershell on Mac via PowerShell Core, though I have experienced a large amount of authentication issues, namely with the Connect-AzureRmAccount command:
Connect-AzureRmAccount : Object reference not set to an instance of an object.
At line:1 char:1
+ Connect-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Connect-AzureRmAccount], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
Help would be appreciated.
Answering my own question.
1. Install Powershell with brew:
brew cask install powershell
2. Verify that your install is working properly:
pwsh
3. Execute the powershell script found here: https://blogs.msdn.microsoft.com/benjaminperkins/2017/04/12/export-an-azure-app-service-certificate-pfx-powershell/

Resources